cmedit.EditSystem = (function($, window, document) {
    var thisContext;
    var ue;
    var mainGuid = getRequestByName("mainGuid");
    $("#mainGuid").val(mainGuid);
    var topUtil; //顶层工具类
    var privilegeIds;
    var imgList = {};
    var Regexs; //定义验证各种格式类型的正则表达式对象
    var lockMsg; //稿件编辑区被锁定的原因
    var userId = window.parent.localStorage.getItem("userId");
    var tenantId = window.parent.localStorage.getItem("tenantId");
    var userName = window.parent.localStorage.getItem("userName");
    var token = window.parent.localStorage.getItem("token");
    var ducpIM = window.parent.sessionStorage.getItem("im_ducp");
    var CFBFlag = window.parent.sessionStorage.getItem("CFBFlag");
    var CREFlag = window.parent.sessionStorage.getItem("CREFlag");
    var lanYunFlag = window.parent.sessionStorage.getItem("lanYunFlag");
	var daguanFlag = window.parent.sessionStorage.getItem("daGuanFlag");
    var rabbitmqFlag = window.parent.sessionStorage.getItem("rabbitmqFlag");
    var rongZhiLianFlag = window.parent.sessionStorage.getItem("rongZhiLianFlag");
//    var rongYunFlag = window.parent.sessionStorage.getItem("rongYunFlag");
    //融云的开关拆分成三个
    var rongYunRRFlag = window.parent.sessionStorage.getItem("rongYunRRFlag");
    var rongYunTAFlag = window.parent.sessionStorage.getItem("rongYunTAFlag");
    var rongYunMCFlag = window.parent.sessionStorage.getItem("rongYunMCFlag");
    var hogeFlag = window.parent.sessionStorage.getItem("hogeFlag");
    var columnInfo = JSON.parse(window.parent.sessionStorage.getItem(cmedit.global.columnInfo));
    var allColumnInfo = JSON.parse(window.parent.sessionStorage.getItem(cmedit.global.allColumnInfo));
    var CREFuncFlag = window.parent.sessionStorage.getItem(cmedit.global.CREFuncFlag);
    var lvFuncFlag = window.parent.sessionStorage.getItem(cmedit.global.lvFuncFlag);
    var distributeFlag = window.parent.sessionStorage.getItem("distributeFlag"); //签发开关(1:cre 2:稿件自己')
    var GifFlag = window.parent.sessionStorage.getItem("GifFlag");
    var SubtitleFlag = window.parent.sessionStorage.getItem("SubtitleFlag");
    var distributeSecretFlag = window.parent.sessionStorage.getItem("distributeSecretFlag");
    var similarityTimer; //获取推荐文章定时器
    var timestamp = new Date().getTime();
    var signMainGuid; //签发要用的稿件id
    var signColumnId; //签发用的稿件栏目id
    var cacheTaskId; //校对用的任务Id
    var misStatus;
    var clbGuid = "";
    var mainStatus = "";
    var lockSessionId = "";
    var unlock  = true;//稿件解锁权限
    var creCbbvFlag = window.parent.sessionStorage.getItem("creCbbvFlag");  //蓝鲸资源库与文件库开关
    var creImportTaskFlag = window.sessionStorage.getItem(cmedit.global.creImportTaskFlag);
    var userColumnIds = window.parent.sessionStorage.getItem(cmedit.global.userColumnIds);
    var EditSystemClass = function() {

    }
    EditSystemClass.prototype = {
        constructor: EditSystemClass,

        init: function() {
            thisContext = this;
            topUtil = window.parent.cmedit.global;
            //从父页面拿到权限信息
            privilegeIds = window.parent.sessionStorage.getItem("privilegeIds");
            Regexs = {
                audio: (/\.(mp3|wav|wma)$/i), //音频格式
                word: (/\.(doc|docx)$/i), //word格式
                image: (/\.jpg$|\.jpeg$|\.gif$/i) // 图片格式
            };
            thisContext.initViewStyle();
            thisContext.initUEditor();
            //初始化开关
            SimpleSwitch.init();
            //            	thisContext.initUserList();
//            thisContext.initUserListByPage();
            thisContext.initSelectList();
            thisContext.initColumn();
            thisContext.initData();
            thisContext.initEvent();
            if(rabbitmqFlag == 1){
                thisContext.initWebSocket();
                thisContext.loadManuscriptUnlock();
            }
        },
        initWebSocket : function(){
            var callback = function(msg){
                var message = JSON.parse(msg);//消息主体
                var mainType = message.mainType;//稿件类型
                var operation = message.operation;//操作类型
                var operator = message.operator;//操作人员
                var serverSessionId = message.sessionId;
                var manuscript = null;
                if(message.manuscript){
                    manuscript = JSON.parse(message.manuscript);//稿件主体信息
                }
                if(operation == "lock" && serverSessionId != lockSessionId && mainGuid == manuscript.mainGuid){
                    setTimeout(function(){
                        thisContext.disableManuscript();
                        thisContext.disableUEditor();
                        if(rabbitmqFlag==1 && unlock){
                        	$("#unlockButton").show();
                        }
                        thisContext.disableManuscript(ue);
                        $("#submitButton").hide();
                        $("#censorButton").hide();
                        $("#saveButton").hide();
                        $('#savebtn').attr("disabled","disabled");
                        $('.tipNote').html("该稿件被"+operator+"抢夺锁！");
                        $('.lockTip').show();
                        //取消锁
                        window.top.sessionStorage.setItem("lock_" + mainGuid, false);
                        //取消自动保存
                        window.parent.cmedit.ManuscriptSystem.clearAutoMenu();
                    },50)
                }
                if(operation == "loginOut" && serverSessionId != lockSessionId && mainGuid == manuscript.mainGuid && operator == userName){
                	window.parent.cmedit.ManuscriptSystem.loginOutManuscript();
                }
            }
            cmedit.websocket.connect("edit",callback);
        },
        /**
         * 初始化页面视图
         */
        initViewStyle: function() {
            $('.editHeight').css('height', $(".editFluid").height() - 144 + 'px');
            $('.cont_right').css('height', $('.editFluid').height() - 84 + 'px');
            $('#info_basic').css('height', $('.tabbable-custom').height() - 44 + 'px');
            $('.otherfile_lists').css('height', $('.tabbable-custom').height() - 98 + 'px');
            $('.cont_left').css('width', $('.re-content').width() - 420 + 'px');
            /*修改滚动条样式*/
            /* var tabbasic_height=$('#info_basic').height();
             thisContext.scrollType('#info_basic',tabbasic_height);*/
            /* var tabextra_height=$('.otherfile_lists').height();
             thisContext.scrollType('.otherfile_lists',tabextra_height);*/
            if (!topUtil.isNotEmpty(mainGuid)) {
                $("#censorHistoryButton").show();
                $("#versionButton").show();
                $("#saveButton").show();
                $("#submitButton").show();
                $("#unlockButton").hide();
                //$("#censorButton").hide();
                if (!topUtil.isNotEmpty($("#edit_title").val())) {
                    $("#edit_title").val("新建稿件_" + timestamp);
                }
                $("#censorButton").hide();
                if (privilegeIds.indexOf(cmedit.global.privilegeDistribute) > -1) { //有稿件权限
                    $("#signButton").show();
                } else {
                    $("#signButton").hide();
                }
                // 签发安全开关开启
                if(distributeSecretFlag == '1'){
                	$("#submitButton").hide();
                }
            }
            if(distributeFlag == '1'){//【长城网定制分发模式，对新建稿件的分发按钮屏蔽】
            	$("#signButton").hide();
            }
            $("#onlySignButton").hide();
            $("#onlySignButton3").hide();
            $('.upLoadpic').css('height', ($(".upLoadpic").width() / 1.8) + 'px');
            /*根据浏览器宽度计算缩略图大小*/
            $('.upload_img').css('height', $('.upload_img').width() / 2);
            $('.upload_operate').css('height', $('.upload_img').width() / 2);
            $('.upload_btns').css('height', $('.upload_img').width() / 2);

            $('.upload_operate').css('minHeight', '74px');
            $('.upload_img').css('minHeight', '74px');
            if ($('.upload_img').height() < 75) {
                $('.upload_btns').css('padding', 0);
            }
            if (GifFlag == 1) {
                $("#gifTab").show();
            } else {
                $("#gifTab").hide();
            }
            if (SubtitleFlag == 1) {
                $("#captionTab").show();
            } else {
                $("#captionTab").hide();
            }
            if (CREFuncFlag == 1) {
                $("#creResourceRecommend").show();
            } else {
                $("#creResourceRecommend").hide();
            }
            if (rongZhiLianFlag == 1) {
                $("#ziyuantuijian").show();
                $("#yuanwenfenxi").show();
                $("#contentLabel").show();

            } else {
                $("#ziyuantuijian").hide();
                $("#yuanwenfenxi").hide();
                $("#contentLabel").hide();
            }

            //                if(rongYunFlag == 1){
            //                	$("#fenxi").show();
            //                	$("#jiaodui").show();
            //                }else{
            //                	$("#fenxi").hide();
            //                	$("#jiaodui").hide();
            //                }
            if (lvFuncFlag == 1) {
                $("#jiaodui").show();
            } else {
                $("#jiaodui").hide();
            }
            // 快融原创分析暂时屏蔽
            $("#originalarticle").hide();

          //融云开关，1为开启 资源推荐
            if (rongYunRRFlag == 1) {
                $("#ryRecommond").show();
            } else if (rongYunRRFlag == 0) {
                $("#ryRecommond").hide();
            }
            
            //融云开关，1为开启 原文分析
            if (rongYunTAFlag == 1) {
                $("#ryOriginal").show();
            } else if (rongYunTAFlag == 0) {
                $("#ryOriginal").hide();
            }
            
            //融云开关，1为开启 稿件查重
            if (rongYunMCFlag == 1) {
                $("#ryRepetition").show();
            } else if (rongYunMCFlag == 0) {
                $("#ryRepetition").hide();
            }
            //                if(rongZhiLianFlag != 1 && rongYunFlag != 1 && CREFuncFlag!= 1 && lvFuncFlag != 1){
            //                if(rongZhiLianFlag != 1 && CREFuncFlag!= 1 && lvFuncFlag != 1){
            if (lvFuncFlag !=1 && rongZhiLianFlag != 1 && rongYunRRFlag !=1 && CREFuncFlag != 1 && rongYunTAFlag !=1 && rongYunMCFlag !=1) {
                $("#moreApp").hide();
            } else {
                $("#moreApp").show();
            }
            if (hogeFlag == 1) { // 厚键分享按钮
                $("#shareButton").show();
            } else {
                $("#shareButton").hide();
            }
            if (ducpIM == 1) { // 协同分享按钮
            	$("#ducpShareButton").show();
            } else {
            	$("#ducpShareButton").hide();
            }
            
            var hogeColumnFlag = window.sessionStorage.getItem("hogeColumnFlag");
        	if(cmedit.global.isNotEmpty(hogeColumnFlag) && hogeColumnFlag == '1'){
        		$("#hogeColumnDiv").show();
        	}

//        	var cmeditList = JSON.parse(window.sessionStorage.getItem(cmedit.global.cmeditTypes));
//            var list = '';
//            for (var key in cmeditList) {
//                if(cmeditList[key] == 2){
//                	list += '<li class="dropmenu-list" ><input  type="checkbox" value="' + cmeditList[key] + '-0" id="'  + key + '-0"><label for="'  + key + '-0">短微博</label></li>';
//                	list += '<li class="dropmenu-list" ><input  type="checkbox" value="' + cmeditList[key] + '-1" id="'  + key + '-1"><label for="'  + key + '-1">头条文章</label></li>';
//                }else{
//                	list += '<li class="dropmenu-list"><input type="checkbox" value="' + cmeditList[key] + '" id="'  + key + '"><label for="'  + key + '">' + key + '</label></li>';
//                }
//            }
//            list += '<li style="line-height:34px;margin-bottom:5px;" class="dropmenu-list"><button class="btn btn-default blue copy-conform" onclick="cmedit.EditSystem.copyManuscript()">确定</button></li>';
//            $("#copyul").html(list);
        },

        copyshow: function() {
            var _con = $("#copyul");
            $("body").off("click").on("click", function(e) {
                if (!_con.is(event.target) && !_con.children().is(event.target) && (_con.has(event.target).length === 0) || _con.find('button').is(event.target)) {
                    $(".moreDropDown").removeClass("showDropDown");
                    _con.removeClass("showDropDown");
                } else {
                    if (_con.is(":hidden")) {
                        $(".showDropDown").removeClass("showDropDown");
                        _con.addClass("showDropDown");
                    };
                }
            });
            return false;
        },
        /**
         * 初始化ueditor编辑器
         */
        initUEditor: function() {
            //初始化ueditor
            var editallscripts = 'PID_CMEDIT_EDITALLSCRIPTS';
            if ($(window).width() > 1530) {
                var ueditHeight = $(".editHeight").height() - 36;
            } else {
                var ueditHeight = $(".editHeight").height() - 64;
            }
            var labelInit = {
                'showword': 'Word导入', //'Word导入',
                /*'waterimage':'美图秀秀',//'美图秀秀',*/
                'webpreview': '发布预览', //'发布预览',
                '135editor': '135editor编辑器', //'135editor编辑器'

            }
            var toolbarsInit = ['source', '|', 'undo', 'redo', '|', 'bold', 'italic', 'underline', 'forecolor', 'backcolor', 'FontFamily', 'FontSize', '|', 'indent', 'justifyleft', 'justifyright', 'justifycenter', 'justifyjustify','lineheight','letterspacing','|', 'insertorderedlist', 'insertunorderedlist', '|', 'insertimage', 'insertvideo', 'link', '|', 'removeformat', 'formatmatch', 'autotypeset',/*'searchreplace',*/ 'inserttable', 'deletetable', 'spechars', 'horizontal', 'print', 'insertimage', 'preview', 'webpreview', 'fullscreen', '|', 'showword', '|', 'localization' /*,'waterimage'*/ ];
            if (CREFlag == 1) {
                labelInit["showcre"] = "CRE资源库", //'CRE资源管理',
                    toolbarsInit.push("showcre");
            }
            //    				}
            if (CFBFlag == 1) {
                labelInit["showxt"] = "文件库", //'协同资源库',
                    toolbarsInit.push("showxt");
            }
            
            if (lanYunFlag == 1) {
            	labelInit["showlanyun"] = "内容库", //'协同资源库',
            	toolbarsInit.push("showlanyun");
            }
			if (daguanFlag == 1) {
             	labelInit["showdaguan"] = "大观资源", //'协同资源库',
             	toolbarsInit.push("showdaguan");
            }
             
            
            //查看自己的稿件，所见编辑区域
            console.log('初始化UEditor...');
            ue = UE.getEditor("editer_", {
                initialFrameHeight: ueditHeight, //设置编辑器高度
                toolbars: [toolbarsInit],
                labelMap: labelInit,
                autoHeightEnabled: false,
                autoFloatEnabled: false
            });
	    console.log(ue);
	    
            ue.ready(function() {
                //隐藏多图上传按钮
                $("#edui84_body").hide();
            });

        },
        /**
         * 重置编辑器高度
         */
        resizeUeditorHeight: function() {
            UE.getEditor('editer_').setHeight($(".editHeight").height() - 36);
        },
        /**
         * 初始化数据
         */
        initData: function() {
            var externalManuscript = JSON.parse(window.top.sessionStorage.getItem("externalManuscript"));
            if (mainGuid) {
                thisContext.initAttachment();
                thisContext.loadInfo(mainGuid);
            } else if (topUtil.isNotEmpty(externalManuscript)) {
                thisContext.initExternal(externalManuscript);
            } else {
                $('.manuLoader').hide();
            }
        },

        /**
         * 复制稿件
         * @param mainGuid 稿件主表id
         * @param mainType 复制目标稿件类型 
         * 【0：CMS稿件 1：微信稿 2：微博稿件 3：电视稿件 4：通稿稿件】
         */
        copyManuscript: function () {
//            $(obj).parents(".dropdown-menu").hide();
            var targetTypeList = $("#copyul").find(".dropmenu-list").find("input:checked");
            var mainType = [];
            if (targetTypeList.length > 0) {
                targetTypeList.each(function (item, value) {
                	if($(value).attr("value")){
                		mainType.push($(value).attr("value"));
                	}
                })
            } else {
                return;
            }
            console.log("mainType", mainType);
            //批量复制为其他类稿件
            topUtil.ajaxRequest({
                type: "post",
                async: true,
                dataType: "json",
                url: cmedit.global.cmsPath + "CmsController/copyManuscriptBatch",
                data: {
                    mainGuid: mainGuid,
                    targetMainType: JSON.stringify(mainType)
                },
                success: function (data) {
                    if (data.status) {
                        $.notify(data.msg);
                        $("#copyul").find(".dropmenu-list").find("input[type='checkbox']").attr("checked",false);
                    } else {
                        $.notify('复制失败');
                    }
                }
            });
        },
        
        /**
         * 初始化附件列表
         */
        initAttachment: function() {
            var attachType = $("#attachType").val();
            var attachName = $("#attachName").val();
            var postData = {
                mainGuid: mainGuid,
                maFileType: attachType,
                maFileName: attachName
            }
            topUtil.ajaxRequest({
                type: "post",
                async: false,
                dataType: "json",
                url: cmedit.global.cmsPath + "ManuscriptAttachmentController/getManuscriptAttachment",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        var attachmentList = data.data;
                        var html = '';
                        if (attachmentList.length > 0) {
                            html = template('attachmentFileList', data);
                        } else {
                            html = '<span class="noResults">暂无数据<span>';
                        }
                        $("#attachmentFileTable").html(html);
                    } else {
                        $.notify(data.msg);
                    }
                }
            });
        },
        /**
         * 对稿件的定时器进行初始化
         */
        initSaveAuto: function(origin) {
            // 判断自动保存功能是否开启
            if (window.sessionStorage.getItem(cmedit.global.saveAutoFlag) == '1') {
                if (origin) { //来源为页签切换(origin为稿件guid)
                    setTimeout(function() {
                            window.parent.cmedit.ManuscriptSystem.saveAutoManu(mainGuid)
                        },
                        parseInt(window.sessionStorage.getItem(cmedit.global.saveInterval)) * 1000);
                } else { //来源为新打开稿件页签
                    window.onload = function() {
                        setTimeout(function() {
                                window.parent.cmedit.ManuscriptSystem.saveAutoManu(mainGuid)
                            },
                            parseInt(window.sessionStorage.getItem(cmedit.global.saveInterval)) * 1000);
                    }
                }
            }
        },
        /**
         * 将一键稿件的信息写入页面
         */
        initExternal: function(cmsManuscript) {
            $('.edit_title').val(cmsManuscript.mainHeader.replace(/&amp;/g, "&"));
            $("#preReportColumn").selectpicker('val', cmsManuscript.mainColumnId);
            $("#mainIsOriginal").selectpicker('val', cmsManuscript.mainIsOriginal);
            $('#mainSources').val(cmsManuscript.mainSources);
            $('#selectInput_text').val(cmsManuscript.mainFolderName ? cmsManuscript.mainFolderName.replace(/&amp;/g, "&") : "");
            //				$("#mainAuthor").selectpicker('val',cmsManuscript.mainAuthor);
//            $('#mainAuthor_text').val(cmsManuscript.mainAuthor ? cmsManuscript.mainAuthor.replace(/&amp;/g, "&") : "");
            $('#mainAuthor').val(cmsManuscript.mainAuthor);
            $('#mainCorrespondent').val(cmsManuscript.mainCorrespondent);
            //$('#cmsEyebrowHead').val(cmsManuscript.cmsEyebrowHead);
            $('#cmsGuid').val(cmsManuscript.cmsGuid);
            $('#cmsSubtitle').val(cmsManuscript.cmsSubtitle);
            $('#mainSummary').html(cmsManuscript.mainSummary);
            $('#cmsSourceUrl').val(cmsManuscript.cmsSourceUrl);
            $('#mainKeyWords').val(cmsManuscript.mainKeyWords);
            //初始化ueditor
            var ue = UE.getEditor("editer_");
            var editallscripts = '';
            if (cmsManuscript.cmsH5Content != null && cmsManuscript.cmsH5Content != "") {
                ue.ready(function() {
                    ue.setContent(cmsManuscript.cmsH5Content);
                    //稿件打开时将富文本内容存入session，用于关闭时比较
                    //window.sessionStorage.setItem(myobj.manuscriptid,base.encode(ue.getContent()));
                });
            } else {
                //window.sessionStorae.setItem(myobj.manuscriptid,"");
            }
            window.top.sessionStorage.removeItem("externalManuscript");
            $('.manuLoader').hide();
        },

        
        /**
         * 加载信息
         */
        loadInfo: function(mainGuid) {
            $('.manuLoader').show();
            var data = {
                "mainGuid": mainGuid
            }

            topUtil.ajaxRequest({
                type: "post",
                async: true,
                /*contentType: "application/json;charset=UTF-8",*/
                dataType: "json",
                url: cmedit.global.cmsPath + "CmsController/getWebManuscriptByGuid",
                data: data,
                success: function(data) {
                    if (data.status) {
                        console.log(data);
                        var cmsManuscript = data.data;
                        var mainGuid = cmsManuscript.mainGuid;
                        mainStatus = cmsManuscript.mainStatus;
                        var mainColumnId = cmsManuscript.mainColumnId;
                        $('.edit_title').val(cmsManuscript.mainHeader.replace(/&amp;/g, "&"));
                        $("#cmsCreateTime").val(cmsManuscript.mainCreateTime);
                        $("#mainCreateUserName").val(cmsManuscript.mainCreateUserName);
                        $("#preReportColumn").val(cmsManuscript.mainColumnId).trigger('change');
                        $("#mainIsOriginal").val(cmsManuscript.mainIsOriginal).trigger('change');
                        $('#mainSources').val(cmsManuscript.mainSources);
                        $('#cmsGuid').val(cmsManuscript.cmsGuid);
                        $('#cmsSubtitle').val(cmsManuscript.cmsSubtitle);
                        $('#mainSummary').html(cmsManuscript.mainSummary);
                        $('#cmsSourceUrl').val(cmsManuscript.cmsSourceUrl);
                        $('#mainKeyWords').val(cmsManuscript.mainKeyWords);
                        $("#createUserId").val(cmsManuscript.mainCreateUserId);
                        $('#selectInput_text').val(cmsManuscript.mainFolderName ? cmsManuscript.mainFolderName.replace(/&amp;/g, "&") : "");
                        //$('#selectInput_text').selectPageRefresh();
                        //    					    if(topUtil.isNotEmpty(cmsManuscript.mainAuthor)){
                        //    					    	$("#mainAuthor").val(cmsManuscript.mainAuthor).trigger('change');
                        //        						$("#mainAuthor").val(cmsManuscript.mainAuthor);
                        //    					    }
//                        $('#mainAuthor_text').val(cmsManuscript.mainAuthor ? cmsManuscript.mainAuthor.replace(/&amp;/g, "&") : "");
                        $('#mainAuthor').val(cmsManuscript.mainAuthor);
                        $('#mainCorrespondent').val(cmsManuscript.mainCorrespondent);
                        if (topUtil.isNotEmpty(cmsManuscript.hjColumnId)) {
                            $("#newsColum").val(cmsManuscript.hjColumnName);
                            $("#newsColum").attr('name', cmsManuscript.hjColumnId);
                        }
                        if (topUtil.isNotEmpty(cmsManuscript.hjIsComment)) {
                            if (cmsManuscript.hjIsComment == 0) {
                                $("#editSwitch").find("button").addClass("on");
                            } else {
                                $("#editSwitch").find("button").removeClass("on");
                            }
                        }
                        var headContent = cmsManuscript.mainHeader.replace(/&amp;/g, "&") + cmsManuscript.mainIsOriginal + cmsManuscript.mainColumnId + cmsManuscript.mainSources +
                            (cmsManuscript.mainFolderName ? cmsManuscript.mainFolderName.replace(/&amp;/g, "&") : "") + cmsManuscript.mainAuthor +cmsManuscript.mainCorrespondent+
                            cmsManuscript.cmsSubtitle + cmsManuscript.mainSummary + cmsManuscript.cmsSourceUrl +
                            cmsManuscript.mainKeyWords + cmsManuscript.cmsLowImage;
                        window.sessionStorage.setItem(mainGuid + "_head", headContent);


                        if (topUtil.isNotEmpty(cmsManuscript.cmsLowImage)) {
                            $(".upLoadBtn").hide();
                            var imgHtml = '<img  src="' + cmsManuscript.cmsLowImage + '">' +
                                '<div class="upLoadEdit">' +
                                '<i class="iconfont icon-bianji" title="修改" onclick="cmedit.EditSystem.uploadLitimgByCFB()"></i>' +
                                '<i class="iconfont icon-shanchu5" title="删除" onclick="cmedit.EditSystem.deleteLitimg()"></i>' +
                                '</div>';
                            $(".uploadImg").html(imgHtml);
                            $(".uploadImg").show();
                            $("#litimgAddr").val(cmsManuscript.cmsLowImage);
                            $("#shotPicLitimg").html('<img src="' + cmsManuscript.cmsLowImage + '">');
                        }
                        var censorFlag = thisContext.hiddenButton(cmsManuscript);
                        thisContext.getConsorHistoryList(cmsManuscript.mainGuid);
                        thisContext.loadOperateList(cmsManuscript.mainGuid);
                        //初始化ueditor
                        var ue = UE.getEditor("editer_");
                        var editallscripts = '';
                        //撤回功能
                        if (cmsManuscript.mainStatus == 1 && userId == cmsManuscript.mainCreateUserId) {
                            var isRevoke = thisContext.isRevokeManuscript(mainGuid);
                            if (isRevoke) {
                                $("#revokeButton").show();
                            }
                        }


                        var lockFlag = false;
                        var lock = false;
                        //如果没有编辑所有的权限， && 当前用户没有稿件编辑权限 或者不是稿件创建者,
//                        if (privilegeIds.indexOf(cmedit.global.privilegeEditallscripts) == -1 &&
//                            (userId != cmsManuscript.mainCreateUserId || privilegeIds.indexOf(cmedit.global.privilegeWritescripts) == -1)) {
//                            lockFlag = false;
//                            lockMsg = "您没有权限编辑当前稿件";
//                            unlock = false;
//                        } else if (cmsManuscript.mainStatus == 2 && privilegeIds.indexOf(cmedit.global.privilegeEditallscripts) == -1) {
//                            lockFlag = false;
//                            lockMsg = "当前为已通过稿件，您没有权限编辑当前稿件";
//                            unlock = false;
//                        }
                        //待提交或者已打回自己创建的稿件可以修改
                        if(userId == cmsManuscript.mainCreateUserId && privilegeIds.indexOf(cmedit.global.privilegeWritescripts) != -1 && (cmsManuscript.mainStatus == 0 || cmsManuscript.mainStatus==3) ){
                        	lockFlag = true;
                            unlock = true;
                        }
                        //有修改本栏目权限，可以修改审核中自己所属栏目的稿件
                        else if(privilegeIds.indexOf(cmedit.global.privilegeEditColumnscripts) != -1 && cmsManuscript.mainStatus == 1 && userColumnIds.indexOf(mainColumnId) !=-1){
                        	lockFlag = true;
                            unlock = true;
                        }
                        
                        //有修改成品稿库权限，可以修改已通过稿件
                        else if(privilegeIds.indexOf(cmedit.global.privilegeEditFinishscripts) != -1 && cmsManuscript.mainStatus == 2){
                        	lockFlag = true;
                            unlock = true;
                        }
                        //有审核修改权限,稿件待审核同时当前人可以审核，可以修改稿件
                        else if(privilegeIds.indexOf(cmedit.global.privilegeEditAuditscripts) != -1 && cmsManuscript.mainStatus == 1 && censorFlag){
                        	lockFlag = true;
                            unlock = true;
                        }else if(privilegeIds.indexOf(cmedit.global.privilegeEditallscripts) != -1 
                        		&& privilegeIds.indexOf(cmedit.global.privilegeEditAuditscripts) == -1
                        		&& privilegeIds.indexOf(cmedit.global.privilegeEditFinishscripts) == -1
                        		&& privilegeIds.indexOf(cmedit.global.privilegeEditColumnscripts) == -1){
                        	lockFlag = true;
                            unlock = true;
                        }
                        else{
                        	lockFlag = false;
                            unlock = false;
                            lockMsg = "您没有权限编辑当前稿件";
                        }
                        var islock  = thisContext.lockManuscript(mainGuid, true,lockFlag);
                        //待审核状态
//                        if (releaseManuscript.mainStatus == 1 && userId == releaseManuscript.mainCreateUserId) {
//                            var isRevoke = thisContext.isRevokeManuscript(mainGuid);
//                            if (isRevoke) {
//                                $("#revokeButton").show();
//                            }
//                        }
                        if (cmsManuscript.cmsH5Content != null && cmsManuscript.cmsH5Content != "") {
                            ue.ready(function() {
                                ue.setContent(cmsManuscript.cmsH5Content);
                                //隐藏多图上传按钮
                                $("#edui84_body").hide();
                                if (!lockFlag) {
                                    ue.setDisabled(['fullscreen', 'print', 'preview', 'webpreview']);
                                }
                                //稿件打开时将富文本内容存入session，用于关闭时比较
                                window.sessionStorage.setItem(mainGuid + "_text", ue.getContent());
                            });
                        } else {
                            ue.ready(function() {
                                $("#edui92_body").hide();
                                if (!lockFlag) {
                                    ue.setDisabled(['fullscreen', 'print', 'preview', 'webpreview']);
                                }
                            });
                            window.sessionStorage.setItem(mainGuid + "_text", "");
                        }
                        if (lockFlag) {
                            window.top.sessionStorage.setItem("lock_" + mainGuid, true);
                        } else {
                            window.top.sessionStorage.setItem("lock_" + mainGuid, false);
                        }
//                        if(rabbitmqFlag==1 && !lock && unlock){
//                        	$("#unlockButton").show();
//                        }else{
//                        	$("#unlockButton").hide();
//                        }
                        
                        if (!lockFlag || !islock) {
                            thisContext.disableManuscript(ue);
                            //    			            	$("#submitButton").hide();
                            //    			            	$("#censorButton").hide();
                            $("#saveButton").hide();
                            if (!lockFlag) {
                                $('.tipNote').html(lockMsg);
                                $('.lockTip').show();
                            }
                        } else {
                            if (!$("#preReportColumn").prop("disabled")) { //稿件处于非禁用状态
                                // 启动自动保存
                                thisContext.initSaveAuto();
                            }
                        }
//                        //已通过稿件且不在该用户所属栏目中只能预览
//                        if(cmsManuscript.mainStatus == 2 && (userColumnIds.indexOf(mainColumnId) ==-1 || distributeSecretFlag==1)){
//                        	$("#preReportColumn").closest('.preReportColumn').html("<input class='form-control' maxlength='50' value='"+cmsManuscript.mainColumnName+"' disabled=''>");
//                        	thisContext.disableManuscript(ue);
//                        	$("#saveButton").hide();
//                        }
                        $('.manuLoader').hide();
                        //签发要用的
                        signMainGuid = mainGuid;
                        signColumnId = cmsManuscript.mainColumnId;
                        misStatus = cmsManuscript.misStatus;
                    } else {
                        console.log(data);
                    }
                }
            });
        },

        /**
         * 生成唯一标识guid
         * @returns
         */
        generateUUID : function() {
            var d = new Date().getTime();
            var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
                var r = (d + Math.random() * 16) % 16 | 0;
                d = Math.floor(d / 16);
                return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
            });
            return uuid;
        },
        
        /**
         * 解锁稿件并抢夺锁。
         */
        unlockAndGrapManuscript : function(){
            var uuid = thisContext.generateUUID();
            lockSessionId = uuid;
            var postData = {
                mainGuid : mainGuid,
                sessionId : lockSessionId,
                sendTo:"webpage.edit"
            }

            topUtil.ajaxRequest({
                type: "post",
                async: true,
                dataType: "json",
                url: cmedit.global.cmsPath + "ManuscriptMainController/unlockAndGrap",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        //解锁稿件
                        thisContext.enableManuscript();
                        thisContext.initData();
                        //开启自动保存
                        thisContext.initSaveAuto();
                        //隐藏解锁按钮
                        $("#unlockButton").hide();
                        $('.tipNote').html("");
                        $('.lockTip').hide();
                        //给稿件加上锁
                        window.top.sessionStorage.setItem("lock_" + mainGuid, true);
                    } else {
                        $.notify("解锁稿件失败！");
                    }
                }
            });
        },
        
        /**
         * 稿件加载判定是否同一个人编辑
         */
        loadManuscriptUnlock :function(){
        	var uuid = thisContext.generateUUID();
        	lockSessionId = uuid;
        	var postData = {
        			mainGuid : mainGuid,
        			sessionId : lockSessionId,
        			sendTo:"webpage.edit"
        	}
        	
        	topUtil.ajaxRequest({
        		type: "post",
        		async: true,
        		dataType: "json",
        		url: cmedit.global.cmsPath + "ManuscriptMainController/loadManuscriptUnlock",
        		data: postData,
        		success: function(data) {
        			console.log(data.msg);
        		}
        	});
        },
        
        
        /**
         * 根据稿件状态隐藏按钮
         */
        hiddenButton: function(cmsManuscript) {
            var postData = {
                "taskGuid": cmsManuscript.mainGuid,
            }
            var censorFlag = false;
            //查看稿件是否能审核
            topUtil.ajaxRequest({
                type: "post",
                async: false,
                dataType: "json",
                url: cmedit.global.cmsPath + "CensorController/isCanAuditTask",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        censorFlag = true;
                    } else {
                        censorFlag = false;
                    }
                    // 判断用户是否有审核权限
                    censorFlag = (privilegeIds.indexOf(cmedit.global.privilegeAuditscripts) > -1 & censorFlag);

                    if (cmsManuscript.mainStatus == 0) {
                        $("#censorHistoryButton").show();
                        $("#operateRecordButton").show();
                        $("#versionButton").show();
                        $("#saveButton").show();
                        if (cmsManuscript.mainCreateUserId == userId) {
                            $("#submitButton").show();
                        }
                    }
                    if (cmsManuscript.mainStatus == 3) {
                        $("#censorHistoryButton").show();
                        $("#operateRecordButton").show();
                        $("#versionButton").show();
                        $("#saveButton").show();
                        if (cmsManuscript.mainCreateUserId == userId) {
                            $("#submitButton").show();
                        }
                    }
                    if (cmsManuscript.mainStatus == 1) {
                        $("#censorHistoryButton").show();
                        $("#operateRecordButton").show();
                        $("#versionButton").show();
                        $("#saveButton").show();
                        if (censorFlag) {
                            $("#censorButton").show();
                        }
                    }
                    if (cmsManuscript.mainStatus == 2) {
                        $("#censorHistoryButton").show();
                        $("#operateRecordButton").show();
                        $("#versionButton").show();
                        $("#saveButton").show();
                    }
                    //如果当前稿件的状态不是带提交和已打回，并且当前用户不是稿件创建人，那么隐藏提交按钮
                    if ((cmsManuscript.mainStatus != 0 && cmsManuscript.mainStatus != 3) || cmsManuscript.mainCreateUserId != userId) {
                        $("#submitButton").hide();
                    }
                    //如果不是待审核状态，隐藏审核按钮
                    if (cmsManuscript.mainStatus != 1 || !censorFlag) {
                        $("#censorButton").hide();
                    }
//                    if (cmsManuscript.mainStatus == 1 && !censorFlag && privilegeIds.indexOf(cmedit.global.privilegeEditallscripts) == -1) { //当前稿件待审核，当前用户不是审核人,且当前用户没有
//                        $("#saveButton").hide();
//                        var ue = UE.getEditor("editer_");
//                        thisContext.disableManuscript();
//                        $('.tipNote').html("当前稿件为待审核状态，您没有权限编辑当前稿件");
//                        $('.lockTip').show();
//                    }

                    // 无签发权限+快融签发
                    if (privilegeIds.indexOf(cmedit.global.privilegeDistribute) == -1) {
                    	$("#signButton").css('display', 'none');
                        $("#onlySignButton").css('display', 'none');
                        $("#signToCreButton").css('display', 'none');
                        $("#onlySignButton3").css('display', 'none');
                    }else{
                    	//如果当前稿件的状态是待提交或已打回 
                        if (distributeFlag == '2' && (cmsManuscript.mainStatus == 0 || cmsManuscript.mainStatus == 3)) {
                            $("#signButton").show();
                            $("#onlySignButton").css('display', 'none');
                            $("#signToCreButton").css('display', 'none');
                            $("#onlySignButton3").css('display', 'none');
                        }
                        //已通过的
                        if (distributeFlag == '2' && cmsManuscript.mainStatus == 2) {
                            $("#onlySignButton").show();
                            $("#signButton").css('display', 'none');
                            $("#signToCreButton").css('display', 'none');
                            $("#onlySignButton3").css('display', 'none');
                        }
                        // ----------------长城网定制签发-------------
                        if (distributeFlag == '1' && cmsManuscript.mainStatus == 2) {
                            $("#signToCreButton").show();
                            $("#signButton").css('display', 'none');
                            $("#signButton").css('display', 'none');
                            $("#onlySignButton").css('display', 'none');
                        }
                        // ----------------分发平台签发-------------
                        //如果当前稿件的状态是待提交或已打回 
                        if (distributeFlag == '3' && (cmsManuscript.mainStatus == 0 || cmsManuscript.mainStatus == 3)) {
                            $("#signButton").show();
                            $("#onlySignButton").css('display', 'none');
                            $("#signToCreButton").css('display', 'none');
                            $("#onlySignButton3").css('display', 'none');
                        }
                        //已通过的
                        if (distributeFlag == '3' && cmsManuscript.mainStatus == 2) {
                            $("#onlySignButton3").show();
                            $("#signButton").css('display', 'none');
                            $("#onlySignButton").css('display', 'none');
                            $("#signToCreButton").css('display', 'none');
                        }
                    }
                    // 签发安全开关开启
                    if(distributeSecretFlag == '1'){
                    	$("#onlySignButton").css('display', 'none');
                    	$("#onlySignButton3").css('display', 'none');
                    	$("#submitButton").hide();
                    }
                }
            });
            return censorFlag;
        },



        /**
         * 禁用稿件编辑区
         */
        disableManuscript: function(ue) {
        	$("#submitButton").hide();
//            $("#censorButton").hide();
            $("#saveButton").hide();
            $("#signButton").hide();
            $("#onlySignButton").hide();
            $("#onlySignButton3").hide();
            $("#signToCreButton").hide();
            $("#moreApp").prop("disabled", "disabled");
            $("#moreApp span").removeAttr("data-toggle");
            $(".isInArticle button").attr("disabled", "disabled");
            $("#preReportColumn").prop("disabled", "disabled");
            $("#mainIsOriginal").prop("disabled", "disabled");
            $("#cmsSubtitle").prop("disabled", "disabled");
            $("#mainSummary").prop("disabled", "disabled");
            $("#mainSources").prop("disabled", "disabled");
            $("#mainFolderName").prop("disabled", "disabled");
            $("#mainAuthor").prop("disabled", "disabled");
            $("#mainCorrespondent").prop("disabled", "disabled");
            $("#cmsSourceUrl").prop("disabled", "disabled");
            $("#edit_title").prop("disabled", "disabled");
            $("#mainKeyWords").prop("disabled", "disabled");
            $(".selectInput").prop("disabled", "disabled");
            $(".selectInput").css("background-color", "#eef1f5");
//            $("#newsColum").removeAttr("onclick");
            $(".upLoadBtn").removeAttr("onclick");
            $(".icon-bianji").removeAttr("onclick");
            $("#newsColum").removeAttr("onclick");
/*            $(".upLoadEdit").css("display", "none"); //缩略图屏蔽
            $(".list_hover").css("display", "none"); //参考资源屏蔽
            $(".uploadImg").on("hover", function() {
                $(".upLoadEdit").css("display", "none");
            });
            $(".list_hover").on("hover", function() {
                $(".list_hover").css("display", "none");
            });*/
            $(".upLoadBtn").removeAttr("onclick");
            $(".upLoadEdit").css("display", "none"); //缩略图屏蔽
            $(".list_hover").css("display", "none"); //参考资源屏蔽
            $("#attachType").prop("disabled", "disabled");
            $("#attachSearch").prop("disabled", "disabled");//参考资源搜索按钮屏蔽
            $('#selectInput').selectPageDisabled(true);
//            $('#mainAuthor').selectPageDisabled(true);
            thisContext.disableUEditor(ue);
        },

        //启用编辑区
        enableManuscript: function(ue) {
            $("#saveButton").show();
            $("#moreApp").removeAttr("disabled");
            $("#moreApp span").attr("data-toggle","dropdown");
            $(".isInArticle button").removeAttr("disabled");
            $("#preReportColumn").removeAttr("disabled");
            $("#mainIsOriginal").removeAttr("disabled");
            $("#cmsSubtitle").removeAttr("disabled");
            $("#mainSummary").removeAttr("disabled");
            $("#mainSources").removeAttr("disabled");
            $("#mainFolderName").removeAttr("disabled");
            $("#mainAuthor").removeAttr("disabled");
            $("#mainCorrespondent").removeAttr("disabled");
            $("#cmsSourceUrl").removeAttr("disabled");
            $("#edit_title").removeAttr("disabled");
            $("#mainKeyWords").removeAttr("disabled");
            $(".selectInput").removeAttr("disabled");
            $(".selectInput").css("background-color", "#eef1f5");
//            $("#newsColum").removeAttr("onclick");
            $(".upLoadBtn").on("click", function() {
            	thisContext.uploadLitimgByCFB();
            })
            $(".icon-bianji").on("onclick",function(){
            	thisContext.uploadLitimgByCFB();
            });
            $("#newsColum").on("onclick",function(){
            	thisContext.newsModal();
            });
           /* $(".uploadImg").on("hover", function() {
                $(".upLoadEdit").css("display", "flex");
            });
            $(".list_hover").on("hover", function() {
                $(".list_hover").css("display", "block");
            });
            $(".upLoadEdit").css("display", "block"); //缩略图屏蔽
            $(".list_hover").css("display", "block"); //参考资源屏蔽
            */          
            $(".uploadImg").on("hover", function() {
                $(".upLoadEdit").css("display", "flex");
            });
            $(".list_hover").on("hover", function() {
                $(".list_hover").css("display", "block");
            });
            $("#attachType").removeAttr("disabled");
            $("#attachSearch").removeAttr("disabled");//参考资源搜索按钮取消屏蔽
            $('#selectInput').selectPageDisabled(false);
//            $('#mainAuthor').selectPageDisabled(false);
            thisContext.enableUEditor(ue);
        },
        
        enableUEditor: function(ue) {
            ue = UE.getEditor("editer_");
            if (ue != null) {
                ue.ready(function() {
                    //ue.setDisabled(['fullscreen','print','preview','webpreview']);
                    ue.setEnabled(['']);
                    //如果为源码模式，将编辑区设置为可视化模式
                    if (ue.queryCommandState('source') && ue.queryCommandState('source') == 1) {
                        ue.execCommand('source');
                    }
                });
            }
            return ue;
        },
        /**
         * 查询稿件操作记录
         */
        loadOperateList: function(guid) {
            var operateTypes = new Array();
            operateTypes.push("新建");
            operateTypes.push("修改");
            operateTypes.push("删除");
            operateTypes.push("提交");
            operateTypes.push("还原");
            operateTypes.push("通过");
            operateTypes.push("打回");
            var postData = {
                "mainGuid": guid,
                operateTypes: JSON.stringify(operateTypes)
            }
            topUtil.ajaxRequest({
                type: "post",
                async: false,
                /*contentType: "application/json;charset=UTF-8",*/
                dataType: "json",
                url: cmedit.global.cmsPath + "ManuscriptMainController/getManuscriptOperateList",
                //data: JSON.stringify({}),
                data: postData,
                success: function(data) {
                    if (data.status) {
                        var listData = {
                            list: data.data,
                        }
                        if (listData.list.length > 0) {
                            var html = template('operateList', listData);
                            $("#operateRecordList").html(html);
                        }
                    } else {
                        $.notify(data.msg);
                    }
                }
            });
        },


        /**
         * 保存稿件
         */
        saveManuscript: function(type) {
            $('.manuLoader').show();
            $("#operateRecordButton").show();
            var cmsGuid = $('#cmsGuid').val() ? $('#cmsGuid').val() : '';
            var cmsSubtitle = $('#cmsSubtitle').val();
            var mainSummary = $('#mainSummary').val();
            //            	var mainAuthor = $("#mainAuthor").val() == "未选取"?"":$("#mainAuthor").val();
            var mainAuthor = $('#mainAuthor').val();
            var mainCorrespondent = $('#mainCorrespondent').val();
            var editTitle = $('#edit_title').val();
            var userColumnIds = window.parent.sessionStorage.getItem(cmedit.global.userColumnIds); //获取部门库
            var columnId = $("#preReportColumn").val() != "" ? $("#preReportColumn").val() : "";
            var columnName = $("#preReportColumn option:selected").text();
            var mainIsOriginal = $("#mainIsOriginal").val() != "" ? $("#mainIsOriginal").val() : "";
            if (!topUtil.isNotEmpty(columnId)) {
                columnName = '';
            }
            var mainSources = $('#mainSources').val() ? $('#mainSources').val() : '';
            var mainId = mainGuid ? mainGuid : "";
            var ue = UE.getEditor("editer_");
            var content = ue.getContent();
            var contentTxt = ue.getPlainTxt();
            var mainFolderName = $('#selectInput').selectPageText();
            var mainFolderId = $('#selectInput').val();
            var iscomment = 1;
            if ($("#editSwitch").find("button").hasClass("on")) {
                iscomment = 0;
            } else {
                iscomment = 1;
            }
            var cmsLowImage = $("#litimgAddr").val() ? $("#litimgAddr").val() : "";
            var hjColumnId = $("#newsColum").attr('name');
            var hjColumnName = $("#newsColum").val();
            var cmsSourceUrl = $('#cmsSourceUrl').val();
            var mainKeyWords = $('#mainKeyWords').val();
            if (editTitle.replace(/^[ ]*$/, "").length == 0) {
                $.notify("稿件标题不能为空");
                $('.manuLoader').hide();
                return false;
            }
            if (type == "submit" || type == 'sign') {
                if (!columnId) {
                    $.notify("提交稿件，栏目不能为空");
                    $('.manuLoader').hide();
                    return false;
                }
                if (!content) {
                    $.notify("提交稿件，正文不能为空");
                    $('.manuLoader').hide();
                    return false;
                }
            }
            if (cmsSourceUrl != null && cmsSourceUrl != '') {
                if (!isPath(cmsSourceUrl)) {
                    $.notify('原文链接有误');
                    $('.manuLoader').hide();
                    return false;
                }

            }
            if(mainAuthor != null && mainAuthor != ''){
            	if(mainAuthor.split(",").length>10){
            		$.notify('人名不超过10个');
                    $('.manuLoader').hide();
                    return false;
            	}
            }
            var postData = {};
            postData.mainGuid = mainId;
            postData.cmsGuid = cmsGuid;
            postData.cmsSubtitle = cmsSubtitle;
            postData.mainSummary = mainSummary;
            postData.mainHeader = editTitle;
            postData.mainColumnId = columnId;
            postData.mainColumnName = columnName;
            postData.mainAuthor = mainAuthor;
            postData.mainCorrespondent = mainCorrespondent;
            postData.mainSources = mainSources;
            postData.mainFolderName = mainFolderName;
            postData.mainFolderId = mainFolderId;
            postData.cmsH5Content = content;
            postData.mainTextContent = contentTxt;
            postData.mainKeyWords = mainKeyWords;
            postData.cmsSourceUrl = cmsSourceUrl;
            postData.hjColumnId = hjColumnId;
            postData.hjColumnName = hjColumnName;
            postData.hjIsComment = iscomment;
            postData.mainIsOriginal = mainIsOriginal;
            postData.userColumnIds = userColumnIds;
            if (type == "autoSave") { //自动刚保存
                postData.isAuto = '1';
            } else {
                postData.isAuto = '0';
            }
            postData.cmsLowImage = cmsLowImage;
            topUtil.ajaxRequest({
                type: "post",
                async: false,
                contentType: "application/json;charset=UTF-8",
                dataType: "json",
                url: cmedit.global.cmsPath + "CmsController/saveOrUpdateCmsManuscript",
                data: JSON.stringify(postData),
                success: function(data) {
                    if (data.status) {
                        if (topUtil.isNotEmpty(mainGuid)) {
                            $('#li_' + mainGuid + ' span', parent.document).html(editTitle);
                            $('#li_' + mainGuid + ' span', parent.document).attr('title', editTitle);
                        } else {
                            mainGuid = data.data.mainGuid;
                            $("#createUserId").val(data.data.mainCreateUserId);
                            $('#li_new a', parent.document).attr('href', '#tab_' + mainGuid);

                            $('#li_new .fa-times-circle', parent.document).attr('onclick', 'cmedit.ManuscriptSystem.removeTab(\'' + mainGuid + '\')');
                            $('#li_new span', parent.document).html(editTitle);
                            $('#li_new span', parent.document).attr('title', editTitle);
                            $('#li_new', parent.document).attr('id', 'li_' + mainGuid);
                            $('#tab_new', parent.document).attr('id', 'tab_' + mainGuid);
                            $('#iframe_new', parent.document).attr('id', 'iframe_' + mainGuid);
                            window.top.sessionStorage.setItem("lock_" + mainGuid, true);
                        }
                        $("#mainGuid").val(mainGuid);
                        signColumnId = data.data.mainColumnId;
                        //保存稿件后将稿件信息存入session
                        var headContent = editTitle + mainIsOriginal + columnId + mainSources +
                            mainFolderName + mainAuthor +mainCorrespondent+
                            cmsSubtitle + mainSummary + cmsSourceUrl +
                            mainKeyWords + cmsLowImage;
                        window.sessionStorage.setItem(mainGuid + "_head", headContent);
                        window.sessionStorage.setItem(mainGuid + "_text", content);
                        window.parent.cmedit.ManuscriptSystem.tablistChange(mainGuid);
                        if (type == 'submit' || type == 'sign') {
                            var submitFlag = true;
                            //判断当前稿件是否是当前用户创建的，如果不是，当前用户不能提交该稿件
                            if ($("#createUserId").val() != userId) {
                                submitFlag = false;
                            }
                            //在父页面写入要提交的稿件id
                            $('#submitMainGuid', parent.document).val(mainGuid);
                            $('#editTitle', parent.document).val(editTitle);

                            //弹出提交弹框
                            if (submitFlag) {
                                if (type == 'sign') {
                                	$("#submitModal", parent.document).attr("operateType","sign");
                                	if(distributeFlag == '2'){
                                		window.parent.cmedit.ManuscriptSystem.getTargetList(data.data.mainColumnId);
                                	}
                                	if(distributeFlag == '3'){
                                		var needCensor = true;
                                		thisContext.sendTaskModal3(needCensor);
//                                		window.parent.cmedit.ManuscriptSystem.getPlatformTargetList(data.data.mainColumnId,mainGuid);
                                	}
                                    
                                    $("#confirmSubmit", parent.document).attr("disabled", true);
                                } else if (type == 'submit') {
                                	$("#submitModal", parent.document).attr("operateType","submit");
                                    //清空弹框的分发内容
                                    window.parent.cmedit.ManuscriptSystem.clearTaskmodal();
                                    thisContext.submitModel(0, mainGuid,columnId);
                                    $("#confirmSubmit", parent.document).attr("disabled", true);
                                }
                            } else {
                                $.notify('提交操作只能是稿件创建人!');
                            }
                            //    							window.parent.cmedit.ManuscriptSystem.initData();
                        } else if (type == "autoSave") {
                            $.notify("自动保存成功");
                        } else if (type == "examine") {} else {
                            $.notify("保存成功");
                            //window.parent.cmedit.ManuscriptSystem.enterDetail(data.data,editTitle);
                        }

                        window.parent.cmedit.ManuscriptSystem.initData();

                    } else {
                        console.log(data);
                    }
                    $('.manuLoader').hide();
                }
            });
            thisContext.loadOperateList(mainGuid);
        },
        
        /**
         * CRE资源推荐
         */
        CREresourceRecommend: function() {
            var loadHtml = '<div id="creRecloading">正在拼命加载中...</div>';
            $("#creResource_BoxContainer").html(loadHtml);
            $("#creResource_LineContainer").html(loadHtml);
            // box
            myCREObj = {};
            myCREObj.resourceList = [];
            var currentPage = 0;
            thisContext.loadCreRecommendRes(currentPage);
            isloaddata = false; // 数据加载过标识
            $(".res-listbox").scroll(function() {
                var viewH = $(this).height(), // 可见高度  
                    contentH = $(this).get(0).scrollHeight, // 内容高度  
                    scrollTop = $(this).scrollTop(); // 滚动条滚过的距离  
                //if(contentH - viewH - scrollTop <= 100) { // 到达底部100px时,加载新内容  
                if (scrollTop / (contentH - viewH) >= 0.97) { // 到达底部97%时,加载新内容  
                    // 这里加载数据..  
                    if (!isloaddata) {
                        currentPage += 6;
                        thisContext.loadCreRecommendRes(currentPage);
                        isloaddata = true;
                    } else {

                    }
                }
            });

            //line
            myCREObj_line = {};
            myCREObj_line.resourceList = [];
            var start = 0;
            thisContext.loadCreRecommendRes_line(start);
            isloaddata_line = false; // 数据加载过标识
            $(".res-listline").scroll(function() {
                var viewH = $(this).height(), // 可见高度  
                    contentH = $(this).get(0).scrollHeight, // 内容高度  
                    scrollTop = $(this).scrollTop(); // 滚动条滚过的距离  
                //if(contentH - viewH - scrollTop <= 100) { // 到达底部100px时,加载新内容  
                if (scrollTop / (contentH - viewH) >= 0.97) { // 到达底部97%时,加载新内容  
                    // 这里加载数据..  
                    if (!isloaddata_line) {
                        start += 6;
                        thisContext.loadCreRecommendRes_line(start);
                        isloaddata_line = true;
                    } else {

                    }
                }
            });
        },
        
        loadCreRecommendRes_line: function(start) {
            var page = start + "";
            var resourceType = new Array();
            var CRErecommend = $('#attachment_typeId').val();
            var title = $('#searchCreRe').val();
            var ue = UE.getEditor("editer_");
            var contentTxt = ue.getPlainTxt();
            postData = {
                userId: userId,
                title: title,
                resourceType: "0,1,2",
                content: contentTxt,
                start: page,
                limit: '6'
            };
            var url = cmedit.global.cmsPath + "CreResouceRecommendNewController/getCreRecommend";
            topUtil.ajaxRequest({
                url: url,
                type: 'POST',
                async: true,
                data: postData,
                dataType: "json",
                success: function(data) {
                    if (data.status) {
                        isloaddata_line = false;
                        if (data.data === null) {
                            var loadHtml = '<div id="creRecnone">cre推荐资源为空</div>';
                            $("#creResource_LineContainer").html(loadHtml);
                            return;
                        } else if (data.data == "") {
                            $.notify("已加载全部数据");
                            return;
                        }
                        console.log("-----资源推荐数据------")
                        console.log(data)
                        isloaddata_line = false;
                        data = data.data;
                        Array.prototype.push.apply(myCREObj_line.resourceList, data.resourceList);
                        thisContext.showLineHtml(myCREObj_line);
                    } else {
                        $.notify(data.msg);
                        var loadHtml = '<div id="creRecnone">cre推荐资源失败</div>';
                        $("#creResource_LineContainer").html(loadHtml);
                    }
                }
            });
        },
        loadCreRecommendRes: function(currentPage) {
            var page = currentPage + "";
            var CRErecommend = $('#attachment_typeId').val();
            var resourceType = new Array();
            var title = $('#searchCreRe').val();
            var ue = UE.getEditor("editer_");
            var contentTxt = ue.getPlainTxt();
            postData = {
                userId: userId,
                title: title,
                resourceType: "0,1,2",
                content: contentTxt,
                start: page,
                limit: '6'
            };
            var url = cmedit.global.cmsPath + "/CreResouceRecommendNewController/getCreRecommend";
            // var url = "http://100.0.0.61:9001/"+"/CreResouceRecommendNewController/getCreRecommend";
            topUtil.ajaxRequest({
                url: url,
                type: 'POST',
                async: true,
                data: postData,
                dataType: "json",
                success: function(data) {
                    if (data.status) {
                        isloaddata = false;
                        if (data.data === null) {
                            var loadHtml = '<div id="creRecnone">cre推荐资源为空</div>';
                            $("#creResource_BoxContainer").html(loadHtml);
                            return;
                        } else if (data.data == "") {
                            $.notify("已加载全部数据");
                            return;
                        }
                        console.log("-----资源推荐数据------")
                        console.log(data)
                        isloaddata = false;
                        data = data.data;
                        Array.prototype.push.apply(myCREObj.resourceList, data.resourceList);
                        thisContext.showBoxHtml(myCREObj);
                    } else {
                        $.notify(data.msg);
                        var loadHtml = '<div id="creRecnone">cre推荐资源失败</div>';
                        $("#creResource_BoxContainer").html(loadHtml);
                    }
                }
            });
        },

        /**
         * 签发弹框
         */
        sendTaskModal: function() {
            var sendTask = function() {
                var mainGuid = signMainGuid;
                var columnId = signColumnId;
                if (topUtil.isNotEmpty(mainGuid)) {
                    var columnIds = [];
                    var mainGuids = [];
                    //判断是单条记录选择的还是勾选的
                    if (topUtil.isNotEmpty(mainGuid)) {
                        singleMainGuid = mainGuid;
                        mainGuids.push(mainGuid);
                        columnIds.push(columnId);
                        //如果入库开关开启了，那么进行签发的时候要判断，如果选中的稿件中有未入库成功的，则不能进行签发
                        /*if (creImportTaskFlag == 1) {
                            if (misStatus != 5) {
                                $.notify("稿件未入库成功，不能进行签发");
                                return;
                            }
                        }*/
                    }
                    var postData = {
                            columnIds: JSON.stringify(columnIds),
                            mainGuids: JSON.stringify(mainGuids),
                        }
                        //获取公共的签发目标
                    topUtil.ajaxRequest({
                        type: "post",
                        async: true,
                        dataType: "json",
                        url: cmedit.global.cmsPath + "CmsController/getCmsTargetSystemArr",
                        data: postData,
                        success: function(data) {
                            if (data.status) {
                                var appendHtml = '';
                                var creTargetList = data.data.creTargetList;
                                var cmsTargetList = data.data.cmsTargetList;
                                if (creTargetList.length > 0 || cmsTargetList.length > 0) {
                                    for (var i = 0; i < creTargetList.length; i++) {
                                        appendHtml += '<div class="mt-checkbox-list">' +
                                            '<label class="mt-checkbox mt-checkbox-outline">' +
                                            '<input type="checkbox" name="targetCheck" id="' + creTargetList[i].creTargetGuid + '">' + creTargetList[i].creTargetName + '' +
                                            '<span></span>' +
                                            '</label>' +
                                            '</div>';
                                    }
                                    for (var i = 0; i < cmsTargetList.length; i++) {
                                        appendHtml += '<div class="mt-checkbox-list">' +
                                            '<label class="mt-checkbox mt-checkbox-outline">' +
                                            '<input type="checkbox" name="targetCheck" id="' + cmsTargetList[i].cmsTargetGuid + '">' + cmsTargetList[i].cmsTargetName + '' +
                                            '<span></span>' +
                                            '</label>' +
                                            '</div>';
                                    }
                                    $("#targetListArr", parent.document).html(appendHtml);
                                    $("input[name='targetCheck']", parent.document).on('change', function() {
                                        var i = $("input[name='targetCheck']:checked", parent.document).length;
                                        if (i > 0) {
                                            $("#confirmDistribute", parent.document).attr("disabled", false);
                                        } else {
                                            $("#confirmDistribute", parent.document).attr("disabled", true);
                                        }
                                    });
                                    $("#confirmDistribute", parent.document).attr("disabled", true);
                                    window.parent.cmedit.ManuscriptSystem.sendTaskModalShow('iframe_' + mainGuid);
                                } else {
                                    $("#targetListArr", parent.document).html("无签发目标");
                                    $("#confirmDistribute", parent.document).attr("disabled", true);
                                    $.notify("无签发目标！");
                                }
                            } else {
                                $.notify(data.msg);
                            }
                        }
                    });
                } else {
                    $.notify("请选择一条稿件进行签发");
                }
            };
            if (!thisContext.isLocalizationImg()) {
                window.parent.cmedit.ManuscriptSystem.confirmLocalization(sendTask);
            } else {
                sendTask();
            }
        },
         /**
         * 签发弹框新增3
         */
        sendTaskModal3: function (needCensor) {
            // 清空modal数据
            $("#sentTaskTreeContainer #book", parent.document).html("");
            $("#sentTaskTreeContainer #keyword", parent.document).val("");
            if (topUtil.isNotEmpty(mainGuid)) {
            	var censorStrategy = thisContext.initCensorPersonSendTaskModal3(mainGuid);
            	if(window.parent.cmedit.ManuscriptSystem.getAsyncCreTarget()){
            		$.notify("请先同步签发目标");
            		return;
            	}
            	if(!censorStrategy.censorStrategyExist){
            		$.notify("审核策略不存在");
            		return;
            	}
            	$("#confirmDistributeButton", parent.document).attr("disabled", true);
                window.parent.cmedit.ManuscriptSystem.sendTaskModal3Show('iframe_manuSendTask');
                $('#selectedSendTargetUl',parent.document).find('li').removeClass("selectedbackground");
                if(!needCensor){
                    $(".censorSendTaskModal3",parent.document).hide();
                	$("#confirmDistributeButton",parent.document).attr("onclick",'cmedit.ManuscriptSystem.confirmDistributeButton()');
                }
                var columnIds = [];
                var mainGuids = [];
                var targetArr;
                //判断是单条记录选择的还是勾选的
                if (topUtil.isNotEmpty(mainGuid)) {
                    mainGuids.push(mainGuid);
                    columnIds.push(signColumnId);
                }
                var postData = {
                    columnIds: JSON.stringify(columnIds),
                    mainGuids: JSON.stringify(mainGuids),
                }
                //获取公共的签发目标
                topUtil.ajaxRequest({
                    type: "post",
                    async: false,
                    dataType: "json",
                    url: cmedit.global.cmsPath + "CmsController/getCmsTargetSystemArr",
                    data: postData,
                    success: function (data) {
                        if (data.status) {
                        	targetArr = data.data.creTargetList;
                        }
                    }
                });
                console.log("公共的签发目标",targetArr);
                
                // 选中的稿件列表
                var mainHeader= $('#edit_title').val();
                var selectedItems = "";
                    selectedItems += ' <li class="selectedLi" mainGuid="'+mainGuid+'">' + mainHeader + '</li>';
                $("#selectedUl", parent.document).html(selectedItems);

                topUtil.ajaxRequest({
                    type: "get",
                    async: true,
                    dataType: "json",
                    url: cmedit.global.cmsPath + 'CreDistributeController/getChannels',
                    data: {
                        channelType: "1,2"
                    },
                    success: function (data) {
                        if (data.status) {
                        // 签发渠道目标
                        debugger;
                        var selectedItems = "";
                        var channelList = data.data.channelList;
                        var channelArry = [];
                        channelList.forEach(function(channel){
                        	targetArr.forEach(function(target){
                        		var channelId = target.creServiceName.replace("CMS_","");
                        		if(channel.channelId == channelId){
                        			channelArry.push(channel);
                        		}
                        	});
                        })
                        console.log("实际签发目标",channelArry);
                        
                        channelArry.forEach(function (v, k, arra) {
                            selectedItems += '<li onclick="cmedit.ManuscriptSystem.showTargetColumnCategory(\'NewsEditingSuite-platform-column-' + v.channelId + '\')" ><label class="mt-checkbox mt-checkbox-single mt-checkbox-outline">';
                            selectedItems +=  '<input channelId="'+v.channelId+'" channelName="'+v.channelName+'" channelType="'+v.channelType+'" distrColumn="" name="issuedTarget" type="checkbox">';
                            selectedItems +=  ' <span></span></label><span >'+v.channelName+'</span></li>'
                            if(topUtil.isNotEmpty(v.columnList))window.sessionStorage.setItem("NewsEditingSuite-platform-column-" + v.channelId,JSON.stringify(v.columnList));
                            if(topUtil.isNotEmpty(v.categoryList))window.sessionStorage.setItem("NewsEditingSuite-platform-category-" + v.channelId,JSON.stringify(v.categoryList));
                            if(topUtil.isNotEmpty(v.moulds))window.sessionStorage.setItem("NewsEditingSuite-platform-moulds-" + v.channelId,JSON.stringify(v.moulds));
                            // <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
                        })
                        $("#selectedSendTargetUl", parent.document).html(selectedItems);
                        if (channelArry.length > 0) {
                            $('#selectedSendTargetUl',parent.document).find('li').on('click',function(){
                        		$('#selectedSendTargetUl',parent.document).find('li').removeClass("selectedbackground");
                        		$(this).addClass("selectedbackground");                      		
                        	});
                            $("input[name='issuedTarget']", parent.document).on('change', function () {
                                //判断是否勾选来展示栏目信息
                                if($(this).prop("checked")){
                                    var channelid = $(this).attr("channelid");
                                    window.parent.cmedit.ManuscriptSystem.showTargetColumnCategory(channelid);
                                    window.parent.cmedit.ManuscriptSystem.showTargetDemo('NewsEditingSuite-platform-moulds-' + channelid);
                                    $("#channelId_hidden",parent.document).val(channelid);
                                }else{
                                	window.parent.cmedit.ManuscriptSystem.showTargetColumnCategory(channelid);
                                	window.parent.cmedit.ManuscriptSystem.showTargetDemo('NewsEditingSuite-platform-moulds-');
                                	$("#channelId_hidden",parent.document).val("");
                                };
                                var i = $("input[name='issuedTarget']:checked", parent.document).length;
                                if (i > 0) {
                                	if(needCensor && $("#censorPerson_sendTaskModal3",parent.document).is(':visible')){
                                		if($("#censorPerson_sendTaskModal3",parent.document).val()){
                                			$("#confirmDistributeButton", parent.document).attr("disabled", false);
                                		}else{
                                			$("#confirmDistributeButton", parent.document).attr("disabled", true);
                                		}
                                	}else{
                                		$("#confirmDistributeButton", parent.document).attr("disabled", false);
                                	}
                                	
                                } else {
                                    $("#confirmDistributeButton", parent.document).attr("disabled", true);
                                }
                            });
                        }
                        if(needCensor){
                        	//指定审核人
                        	if(censorStrategy.isCensorPersonShow){
                        		thisContext.initCensorPersonShow(signColumnId,mainGuid)
                        		$(".censorSendTaskModal3",parent.document).show();
                        		$(parent.document).on('change',"#censorPerson_sendTaskModal3",function(){
                        			var i = $("input[name='issuedTarget']:checked", parent.document).length;
                        			var cval = $("#censorPerson_sendTaskModal3",parent.document).val();
                        			if(i > 0 && cval){
                        				$("#confirmDistributeButton", parent.document).attr("disabled", false);
                        			}else{
                        				$("#confirmDistributeButton", parent.document).attr("disabled", true);
                        			}
                        		})
                        	}else{
                                $(".censorSendTaskModal3",parent.document).hide();
                        	}
                        	$("#confirmDistributeButton",parent.document).attr("onclick",'cmedit.ManuscriptSystem.submitManuscript()');
                        }
                        // 签发目标
                        } else {
                            $.notify(data.msg);
                        }
                    }
                });
            } else {
                $.notify("请选择一条稿件进行签发");
            }
        },
        
        /**
         * 初始化审核人员列表
         */
        initCensorPersonSendTaskModal3: function(mainGuid) {
        	var postData = {
        			mainGuid: mainGuid
            }
        	var isCensorPersonShow = false;
        	var censorStrategyExist = false;
        	var censorStrategy = {};
            topUtil.ajaxRequest({
                type: "post",
                async: false,
                dataType: "json",
                url: cmedit.global.cmsPath + "ManuscriptMainController/censorStrategyExist",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        //如果是指定审核人
                        if (data.data[0].cstIsNominator == 1) {
                        	isCensorPersonShow = true;
                        }
                        censorStrategyExist = true;
                    } 
                }
            });
            censorStrategy.isCensorPersonShow = isCensorPersonShow;
            censorStrategy.censorStrategyExist = censorStrategyExist;
            return censorStrategy;
        },
        
        initCensorPersonShow:function(mainColumnId,mainGuid){
        	var postData = {
        			columnId: mainColumnId,
        			mainGuid: mainGuid
        	}
        	topUtil.ajaxRequest({
        		type: "post",
        		async: true,
        		/*contentType: "application/json;charset=UTF-8",*/
        		dataType: "json",
        		url: cmedit.global.cmsPath + "UserInfoController/getCensorPersonList",
        		//data: JSON.stringify({}),
        		data: postData,
        		success: function(data) {
        			if (data.status) {
        				var list = data.data;
        				var appendHtml = '<option value="">请选择</option>';
        				for (var i = 0; i < list.length; i++) {
        					appendHtml += '<option value="' + list[i].id + '">' + list[i].name + '</option>';
        				}
        				var censorPerson = '<select id="censorPerson_sendTaskModal3" class="selectpicker bs-select form-control" data-live-search="true" data-size="8">' + appendHtml + '</select>';
        				var nextCensor = '<select id="nextCensor_sendTaskModal3" class="selectpicker bs-select form-control" data-live-search="true" data-size="8">' + appendHtml + '</select>';
        				$('#checkSelect_sendTaskModal3', parent.document).html('');
        				$('#checkSelect_sendTaskModal3', parent.document).html(censorPerson);
        				$('#nextCensorSelect_sendTaskModal3', parent.document).html('');
        				$('#nextCensorSelect_sendTaskModal3', parent.document).html(nextCensor);
        				/*$("#censorPerson",parent.document).append(appendHtml);*/
        				//$("#nextCensor",parent.document).html(appendHtml);
        				$("#censorPerson_sendTaskModal3", parent.document).selectpicker('refresh');
        				$("#nextCensor_sendTaskModal3", parent.document).selectpicker('refresh');
        			} else {
        				$.notify(data.msg);
        			}
        		}
        	});
        },
        
        /**
         * 点击确定签发更改签发记录
         */
        determineTarget: function(obj) {
            window.parent.cmedit.ManuscriptSystem.determineTarget(obj);
        },

        /**
         * 点击分发
         */
        sendTaskForm: function() {
            var sendTask = function() {
                var mainGuid = signMainGuid;
                var columnId = signColumnId;
                var columnIds = [];
                var mainGuids = [];
                //判断是单条记录选择的还是勾选的
                if (topUtil.isNotEmpty(mainGuid)) {
                    singleMainGuid = mainGuid;
                    mainGuids.push(mainGuid);
                    columnIds.push(columnId);
                    //如果入库开关开启了，那么进行签发的时候要判断，如果选中的稿件中有未入库成功的，则不能进行签发
                    /*if (creImportTaskFlag == 1) {
                        if (misStatus != 5) {
                            $.notify("稿件未入库成功，不能进行签发");
                            return;
                        }
                    }*/
                }
                var postData = {
                    columnIds: JSON.stringify(columnIds),
                    mainGuids: JSON.stringify(mainGuids),
                }
                topUtil.ajaxRequest({
                    type: "post",
                    async: true,
                    dataType: "json",
                    url: cmedit.global.cmsPath + "CmsNewTargetController/bulkIssueTarget",
                    data: postData,
                    success: function(data) {
                        if (data.status) {
                            //   	   						var url="http://10.10.1.32:8080/distributemanager/application/initDistributePage";
                            var url = data.data.targetUrl;
                            var arg = data.data;
                            window.parent.cmedit.ManuscriptSystem.formSubmit(url, arg);
                        } else {
                            $.notify(data.msg);
                        }
                    }
                });
            };
            if (!thisContext.isLocalizationImg()) {
                window.parent.cmedit.ManuscriptSystem.confirmLocalization(sendTask);
            } else {
                sendTask();
            }
        },
        /**
         * 实际签发操作
         * @param columnIds
         */
        distributeTarget: function(targetIds) {
            var postData;
            var mainGuids = [];
            //判断是单条记录选择还是勾选的
            if (topUtil.isNotEmpty(signMainGuid)) {
                mainGuids.push(signMainGuid);
                postData = {
                    targetIds: JSON.stringify(targetIds),
                    mainGuids: JSON.stringify(mainGuids),
                }
                topUtil.ajaxRequest({
                    type: "post",
                    async: true,
                    dataType: "json",
                    url: cmedit.global.cmsPath + "CmsNewTargetController/batchDistribute",
                    data: postData,
                    success: function(data) {
                        if (data.status) {
                            $.notify("签发稿件成功");
                        } else {
                            $.notify(data.msg);
                        }
                    }
                });
            } else {
                $.notify("无稿件签发！");
            }
        },
        
        /**
         * 获取审核历史
         */
        getConsorHistoryList: function(cmsGuid) {
            var postData = {
                "taskGuid": cmsGuid,
            }
            topUtil.ajaxRequest({
                type: "post",
                async: false,
                dataType: "json",
                url: cmedit.global.cmsPath + "CensorController/getCensorDetailOpition",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        var listData = {
                            list: data.data,
                        }
                        if (listData.list.length > 0) {
                        	if(mainStatus == 1){
                        		listData.list.forEach(function(item){
                        			var censorDetailOpition = item.censorDetailOpition;
                        			censorDetailOpition.forEach(function(e){
                        				if(e.clbState == 1 && e.clbIsNew == 1){
                        					clbGuid = e.clbGuid;
                        					console.log("当前活动审核级别id:----->"+clbGuid);
                        				}
                        				if(e.clbCensorState == 4 && e.clbState == 1){
                        					e.clbCensorState = 1;
                        				}
                        			})
                        		})
                        	}else if(mainStatus == 2 || mainStatus == 3){
                        		clbGuid = listData.list[0].censorDetailOpition[0].clbGuid;
                        		console.log("最大审核级别id:----->"+clbGuid);
                        	}
                        	
                            var html = template('censorHistoryList', listData);
                            $("#censorHistory").html(html);
                            $('.check_fade').first().trigger('click');
                        }
                    } else {
                        $.notify(data.msg);
                    }
                }
            });
        },


        /**
         * 锁定/解锁稿件
         */
        lockManuscript: function(mainGuid, lockOrUnlock,editFlag) {
            var flag = false;
            var postData = {
                mainGuid: mainGuid,
                privilegeIds: editFlag,
                lockOrUnlock: lockOrUnlock,
            };
            topUtil.ajaxRequest({
                type: 'POST',
                url: cmedit.global.cmsPath + 'ManuscriptMainController/lockOrUnlockManuscript',
                data: postData,
                dataType: 'json',
                async: false,
                success: function(data) {
                    if (data.status) {
                        flag = true;
                    } else {
                        $.notify(data.msg);
                        lockMsg = data.msg;
						$('.tipNote').html(data.msg);
						$('.lockTip').show();
                        flag = false;
                        if(rabbitmqFlag==1 && unlock){
                        	$("#unlockButton").show();
                        }
                    }
                }
            });
            return flag;
        },

        /**
         * 禁用UEditor
         */
        disableUEditor: function(ue) {
            /*var isCREResources = $("#isCREResources",top.document).val();
            	
            //CRE资源管理标识
            var isCFBResources = $("#isCFBResources",top.document).val();*/

            var toolbarsInit = ['source', '|', 'undo', 'redo', '|', 'bold', 'italic', 'underline', 'forecolor', 'backcolor', 'FontFamily', 'FontSize', '|', 'indent', 'justifyleft', 'justifyright', 'justifycenter', 'justifyjustify', '|', 'insertorderedlist', 'insertunorderedlist', 'selectall', '|', 'link', 'date', 'time', '|', 'removeformat', 'formatmatch',  'autotypeset', 'searchreplace', 'map', 'inserttable', 'deletetable', 'spechars', 'horizontal', 'print', 'simpleupload', 'insertimage', 'insertvideo', 'preview', 'webpreview', 'fullscreen', '|', 'showattachment', 'showaudio', 'showword', '135editor', /*'waterimage'*/ ];

            /*if(isCREResources == "0"){
            	toolbarsInit.push("showcre");
            }
            if(isCFBResources == "0"){
            	toolbarsInit.push("showxt");
            }*/

            ue = UE.getEditor("editer_", {
                toolbars: [toolbarsInit],
                autoHeightEnabled: false,
                autoFloatEnabled: false,
                readonly: true
            });
            if (ue != null) {
                ue.ready(function() {
                    ue.setDisabled(['fullscreen', 'print', 'preview', 'webpreview']);
                });
            }
            thisContext.resizeUeModal();
            $(".disabledEditerModal").css("display", "block");
            return ue;
        },

        resizeUeModal: function() {
            if ($(window).width() > 1530) {
                $(".disabledEditerModal").css("top", "95px");
            } else {
                $(".disabledEditerModal").css("top", "123px");
            }
        },

        /**
         * 初始化事件
         */
        initEvent: function() {

            /*$("#setAsLitimg").off('click').on('click',function(){
            	thisContext.setAsLitimg();
            });
            	
            $("#useGif").off('click').on('click',function(){
            	thisContext.useGif();
            });*/
            $("#attachType").on('change', function() {
                thisContext.initAttachment();
            });

            $('.check_fade').on('click', function() {
                if ($(this).find('.fa').hasClass('fa-angle-down')) {
                    $(this).find('.fa').removeClass('fa-angle-down');
                    $(this).find('.fa').addClass('fa-angle-up');
                    $(this).find('.checkone_isfade').html('收起');
                    $(this).next().show();
                } else {
                    $(this).find('.fa').removeClass('fa-angle-up');
                    $(this).find('.fa').addClass('fa-angle-down');
                    $(this).find('.checkone_isfade').html('展开');
                    $(this).next().hide();
                }
            });
            $('#info_basic').scroll(function() {
                $(".sp_result_area").hide();
            });
            $('#operateRecordButton').off('click').on('click', function() {
                $(".cont_right>div").not(".messagetabs").hide();
                $('.checkCont').show();
                $('#checkRecordTitle').html("操作记录");
                $('#censorHistory').hide();
                $('#operateRecord').show();
                $('#imageProperty').hide();
            });

            $('#censorHistoryButton').off().on('click', function() {
                $(".cont_right>div").not(".messagetabs").hide();
                $('#checkRecordBox').show();
                $('.checkCont').show();
                $('#checkRecordTitle').html("审核历史");
                $('#operateRecord').hide();
                $('#censorHistory').show();
                $('#imageProperty').hide();
            });

            $("#mainSources").off('keyup').on('keyup', function() {
                thisContext.checkWordLength($(this));
            });

            $("#mainSummary").off('keyup').on('keyup', function() {
                thisContext.checkWordLength($(this));
            });

            $("#cmsSubtitle").off('keyup').on('keyup', function() {
                thisContext.checkWordLength($(this));
            });

            $("#mainKeyWords").off('keyup').on('keyup', function() {
                thisContext.checkWordLength($(this));
            });

            $("#cmsSourceUrl").off('keyup').on('keyup', function() {
                thisContext.checkWordLength($(this));
            });

            $("#attachSearch").off('click').on('click', function() {
                thisContext.initAttachment();
            });

            /*$('#shotBtn').off('click').on('click',function(){
                thisContext.shotPic();
            });
                
            $('#getGif').off('click').on('click',function(){
                thisContext.getGif();
            });*/
            $('.checkClose').off('click').on('click', function() {
                $('.checkCont').hide();
                cmedit.EditSystem.initAttachment();
            });
            $('.recommendOpen').off('click').on('click', function() {
                thisContext.initRonglianCommend(1);
            });
            
         // --cre资源推荐--
            $('#creResourceRecommend').off('click').on('click', function() {
                $(".cont_right>div").not(".messagetabs").hide();
                $(".creVedioPreview").show();
                $(".searchCreReIcon").off("click").on("click", function() {
                    thisContext.CREresourceRecommend()
                })
                thisContext.CREresourceRecommend();
            });
            $('#creResourceRecommendClose').off('click').on('click', function() {
                $(".creVedioPreview").hide();
            });
            // --融云融云资源推荐--
            $('#ryRecommond').off('click').on('click', function() {
                $(".cont_right>div").not(".messagetabs").hide();
                $(".resource_recommend").show();
                thisContext.initRongyunRecommond();
                //                	$('.resource_recommend').show();
            });
            
            //融云原文分析
            $('#ryOriginal').off('click').on('click', function() {
                $(".cont_right>div").not(".messagetabs").hide();
                $("#original_analysis_content").html("原文分析");
                $(".original_analysis").show();
                thisContext.initRongyunOriginal();
            });

            //融云稿件查重
            $('#ryRepetition').off('click').on('click', function() {
                $(".cont_right>div").not(".messagetabs").hide();
                $("#original_analysis_content").html("稿件查重");
                $(".original_analysis").show();
                thisContext.initRongyunRepetition();
            });
            
            $('#yuanwenfenxi').off('click').on('click', function() {
                thisContext.getSimilarityArticle();
            });
            $('#contentLabel').off('click').on('click', function() {
                thisContext.contentLabel();
            });
            $('#jiaodui').off('click').on('click', function() {
                thisContext.jiaoDuiContentLabel();
            });
            $('.contentlabel .checkClose').off('click').on('click', function() {
                $('.contentlabel').hide();
            })
            $('.jiaoDuilabel .checkClose').off('click').on('click', function() {
                $('.jiaoDuilabel').hide();
            })
            $('.recommendClose').off('click').on('click', function() {
                $('.resource_recommend').hide();
            })
            $('.originalClose').off('click').on('click', function() {
                clearTimeout(similarityTimer); //关闭定时器
                $('.original_analysis').hide();
            })
            $('.selectInput').off('click').on('click', function() {
                $('.sp_result_area').css('width', $('.selectInput').width() + 'px');
            });
//            $('.mainAuthor').off('click').on('click', function() {
//                $('.sp_result_area').css('width', $('.selectInput').width() + 'px');
//            });
            $('.info_extra').off('click').on('click', function() {
                $('.tabmess_container .tab-content').find('.slimScrollDiv:nth-child(2)').show();
                $('.tabmess_container .tab-content').find('.slimScrollDiv:nth-child(1)').hide();
            });
            $('.info_basic').off('click').on('click', function() {
                $('.tabmess_container .tab-content').find('.slimScrollDiv:nth-child(1)').show();
                $('.tabmess_container .tab-content').find('.slimScrollDiv:nth-child(2)').hide();
            });

            $('#litimg_file').off('change').on('change', function() {
                thisContext.uploadLocalLitimg();
            });

            /*$('#batchInsert').off('click').on('click',function(){
            	thisContext.batchInsert(0);
            });*/

            // word导入表单异步提交
            $("#word_form_submit").on("click", function() {
                $('.manuLoader').show();
                var manuscriptid = $("input[name='word_manuscriptid']").val();
                if (thisContext.chkFormat($("#word_file").val(), 'word')) { //验证上传格式
//                	var fileSize = document.getElementById("word_file").files[0].size / 1024;
//                    if (fileSize > 5120) {
//                        $('.manuLoader').hide();
//                        $.notify("word大小不能超过5M");
//                        return false;
//                    } else {
//                    }
                	 $("#word_uploadform").on("submit", function() {
                         $("#word_uploadform").ajaxSubmit({
                             type: 'post', // 提交方式
                             url: cmedit.global.cmsPath.replace("gateway/dywebpageserver/","gateway/zuul/dywebpageserver/") + 'UploadController/importWord', // 需要提交的
                             beforeSend: function(XHR) {
                                 XHR.setRequestHeader("userId", encodeURIComponent(userId));
                                 XHR.setRequestHeader("tenantId", tenantId);
                                 XHR.setRequestHeader("token", token);
                                 XHR.setRequestHeader("userName", encodeURIComponent(userName));
                             },
                             success: function(data) {
                                 try {
                                     // 获取uediter实例
                                     var ue = UE.getEditor("editer_");
                                     //            								ue.setContent(data.data,true);  //插入文件末尾
                                     ue.execCommand('insertHtml', data.data);
                                     $('.manuLoader').hide();
                                     $.notify(data.msg);
                                     // 解除事件绑定
                                     $("#word_uploadform").unbind("submit");
                                     $("#word_file").val("");
                                 } catch (exception) {
                                     window.top.message(window.top.i18n("public_import_word_exception")); //导入Word异常
                                     $('.manuLoader').hide();
                                     $.notify(exception);
                                 }
                             }
                         });
                         return false; // 阻止表单自动提交事件
                     });
                } else {
                    $.notify("word格式错误，只支持：doc|docx");
                }
            });
        },

        /**
         * 审核历史展开关闭
         */
        openCloseHistory: function(open) {
            if ($(open).find('.fa').hasClass('fa-angle-down')) {
                $(open).find('.fa').removeClass('fa-angle-down');
                $(open).find('.fa').addClass('fa-angle-up');
                $(open).find('.checkone_isfade').html('收起');
                $(open).parent().next().show();
                $(open).parent().removeClass("back-none");
            } else {
                $(open).find('.fa').removeClass('fa-angle-up');
                $(open).find('.fa').addClass('fa-angle-down');
                $(open).find('.checkone_isfade').html('展开');
                $(open).parent().next().hide();
                if($(open).parent().siblings().length==0){
                	$(open).parent().addClass("back-none");
                }                
            }
        },

        /**
         * 审核弹框
         */
        editModal: function() {
            var columnId = $("#preReportColumn").val() != "" ? $("#preReportColumn").val() : "";
            var postData = {
                "mainGuid": mainGuid
            }
            topUtil.ajaxRequest({
                type: "post",
                async: true,
                dataType: "json",
                url: cmedit.global.cmsPath + "ManuscriptMainController/censorStrategyExist",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        //审核保存操作
                        thisContext.saveManuscript("examine");
                        $('#censorMainGuid', parent.document).val(mainGuid);
                        $('#isStepback',parent.document).val(data.data[0].cstIsStepback);
                        //清空审核弹框里的数据
                        $('#censorPass', parent.document).prop("checked", "checked");
                        $('#auditComments', parent.document).val("");
                        //根据是否是指定审核人判断弹哪种框
                        if (data.data[0].cstIsNominator == 1) {
                        	thisContext.initCensorPerson(columnId, mainGuid);
                            window.parent.cmedit.ManuscriptSystem.taskmodalShow(1);
                        } else {
                            window.parent.cmedit.ManuscriptSystem.taskmodalShow(0);
                        }
                    } else {
                        $.notify(data.msg);
                    }
                }
            });
        },
        /**
         * 版本管理弹框(显示版本列表信息)
         */
        versionModal: function() {
            window.parent.cmedit.ManuscriptSystem.versionmodalShow(mainGuid);
        },
        /**
         * 新媒体栏目弹窗
         */
        newsModal: function() {
            if (!topUtil.isNotEmpty(mainGuid)) {
                thisContext.saveManuscript('auto');
                mainGuid = $("#mainGuid").val();
            }
            window.sessionStorage.setItem("newMainGuid", mainGuid);
            window.parent.cmedit.ManuscriptSystem.newsModalShow($("#newsColum").attr("name"));
        },
        /**
         * 弹出提交模态框
         */
        submitModel: function(columnCount, submitGuid,columnId) {
            var postData = {
                "mainGuid": submitGuid
            }
            topUtil.ajaxRequest({
                type: "post",
                async: true,
                dataType: "json",
                url: cmedit.global.cmsPath + "ManuscriptMainController/censorStrategyExist",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        //如果是指定审核人
                        if (data.data[0].cstIsNominator == 1) {
                            thisContext.initCensorPerson(columnId, mainGuid);
                            window.parent.cmedit.ManuscriptSystem.taskmodalShow(1, true);
                        } else {
                            //如果有签发权限
                            if (privilegeIds.indexOf(cmedit.global.privilegeDistribute) > 0) {
                                //如果栏目数量为空
                                if (columnCount == 0) {
                                    window.parent.cmedit.ManuscriptSystem.submitManuscript();
                                } else {
                                    window.parent.cmedit.ManuscriptSystem.taskmodalShow(0, true);
                                }
                            } else {
                                window.parent.cmedit.ManuscriptSystem.submitManuscript();
                            }
                        }
                    } else {
                        $.notify(data.msg);
                    }
                }
            });
        },
        /**
         *  初始化栏目
         */
        initColumn: function() {
            var userColumnIds = window.parent.sessionStorage.getItem(cmedit.global.userColumnIds);
            var bigColumnId = window.parent.sessionStorage.getItem(cmedit.global.bigColumnId);
            //判断该用户是否属于大采访部
            if (userColumnIds.indexOf(bigColumnId) > -1) {
            	$("#preReportColumn").empty();
            	$("#preReportColumn").append('<option value="">未选取</option>');
                for (var i = 0; i < allColumnInfo.length; i++) {
                    $("#preReportColumn").append('<option value="' + allColumnInfo[i].id + '">' + allColumnInfo[i].name + '</option>');
                }
            } else {
            	$("#preReportColumn").empty();
            	$("#preReportColumn").append('<option value="">未选取</option>');
                for (var i = 0; i < columnInfo.length; i++) {
                    $("#preReportColumn").append('<option value="' + columnInfo[i].id + '">' + columnInfo[i].name + '</option>');
                }
            }
            $("#preReportColumn").select2();
            $("#preReportColumn").selectpicker('refresh');
        },

        /**
         * 初始化作者列表(不分页)
         */
        initUserList: function() {

            var postData = {
                "key": "0003",
            }
            topUtil.ajaxRequest({
                type: "post",
                async: false,
                dataType: "json",
                url: cmedit.global.cmsPath + "UserInfoController/getCreUserListByPrivilige",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        var list = data.data;
                        var appendHtml = '';
                        for (var i = 0; i < list.length; i++) {
                            $("#mainAuthor").append('<option value="' + list[i].name + '">' + list[i].name + '</option>');
                        }

                        /*$("#censorPerson",parent.document).append(appendHtml);*/
                        $("#mainAuthor").select2({
                            tags: true
                        });
                        //$("#nextCensor",parent.document).html(appendHtml);
                        $("#mainAuthor").selectpicker('refresh');
                    } else {
                        $.notify(data.msg);
                    }
                }
            });
        },
        /**
         * 初始化作者列表(分页)
         */
        initUserListByPage: function() {
            var columnId = $("#preReportColumn").val();
            if (columnId == "") {
                var allColumnIds = JSON.parse(window.sessionStorage.getItem(cmedit.global.allColumnIds));
                for (var i = 0; i < allColumnIds.length; i++) {
                    columnId += allColumnIds[i] + ",";
                }
                columnId = columnId.substr(0, columnId.length - 1);
            }
            var postData = {
                userId: userId,
                tenantId: tenantId,
                token: token,
                columnIds: columnId,
            }
            $('#mainAuthor').selectPage({
                searchField: 'name',
                showField: 'name',
                keyField: 'name',
                data: cmedit.global.cmsPath + "UserInfoController/getCreUserListByPage",
                params: function() {
                    var searchContent = $("#mainAuthor_text").attr("searchcontent");
                    if (searchContent) {
                        postData.searchContent = $('#mainAuthor').selectPageText().replace(searchContent, "");
                    } else {
                        postData.searchContent = $('#mainAuthor').selectPageText();
                    }
                    return postData
                },
                eAjaxSuccess: function(data) {
                    var gridResult = data.data;
                    gridResult.totalRow = data.data.totalCount;
                    var result;
                    if (gridResult) result = gridResult;
                    else result = undefined;
                    return result;
                },
                eSelect: function(data) {
                    $('#mainAuthor_text').attr("searchcontent", data.name.replace(data.name, ""));
                }
            });
        },
        /**
         * 初始选题信息
         */
        initSelectList: function() {
            var postData = {
                userId: userId,
                tenantId: tenantId,
                token: token,
            }
            $('#selectInput').selectPage({
                searchField: 'name',
                showField: 'title',
                keyField: 'id',
                data: cmedit.global.cmsPath + "UserInfoController/getCreFolder",
                params: function() {
                    var searchContent = $("#selectInput_text").attr("searchcontent");
                    if (searchContent) {
                        postData.searchContent = $('#selectInput').selectPageText().replace(searchContent, "");
                    } else {
                        postData.searchContent = $('#selectInput').selectPageText();
                    }
                    return postData
                },
                eAjaxSuccess: function(data) {
                    var gridResult = data.data;
                    gridResult.totalRow = data.data.totalCount;
                    var result;
                    if (gridResult) result = gridResult;
                    else result = undefined;
                    return result;
                },
                eSelect: function(data) {
                    $('#selectInput_text').attr("searchcontent", data.title.replace(data.name, ""));
                }
            });
        },

        /* initSelectList : function(){
            	var userId = window.sessionStorage.getItem("userId");
            	var postData = {
            			userId:userId
            	}
            	$('#selectInput').selectPage(
            			{
								showField : 'name',
								keyField : 'id',
								data : cmedit.global.cmsPath+"UserInfoController/getCreFolder",
								params : function(){return postData},
								eAjaxSuccess : function(data){
									var gridResult = data.data;
									//gridResult.totalRow = data.data.totalCount;
							        var result;
							        if(gridResult) result = gridResult;
							        else result = undefined;
							        return result;
							    }
							}
            			);
            },
            */
        /**
         * 初始化审核人员列表
         */
        initCensorPerson: function(mainColumnId, mainGuid) {
            var postData = {
                columnId: mainColumnId,
                mainGuid: mainGuid
            }
            topUtil.ajaxRequest({
                type: "post",
                async: false,
                dataType: "json",
                url: cmedit.global.cmsPath + "UserInfoController/getCensorPersonList",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        var list = data.data;
                        var appendHtml = '<option value="">请选择</option>';
                        for (var i = 0; i < list.length; i++) {
                            appendHtml += '<option value="' + list[i].id + '">' + list[i].name + '</option>';
                        }
                        var censorPerson = '<select id="censorPerson" class="selectpicker bs-select form-control" data-live-search="true" data-size="8">' + appendHtml + '</select>';
                        var nextCensor = '<select id="nextCensor" class="selectpicker bs-select form-control" data-live-search="true" data-size="8">' + appendHtml + '</select>';
                        $('#checkSelect', parent.document).html('');
                        $('#checkSelect', parent.document).html(censorPerson);
                        $('#nextCensorSelect', parent.document).html('');
                        $('#nextCensorSelect', parent.document).html(nextCensor);
                        /*$("#censorPerson",parent.document).append(appendHtml);*/
                        //$("#nextCensor",parent.document).html(appendHtml);
                        $("#censorPerson", parent.document).selectpicker('refresh');
                        $("#nextCensor", parent.document).selectpicker('refresh');
                    } else {
                        $.notify(data.msg);
                    }
                }
            });
        },
        /**
         *滚动条样式
         */
        scrollType: function(scrollId, scrollHeight) {
            $(scrollId).slimScroll({
                height: scrollHeight, //可滚动区域高度
                size: '5px', //组件宽度
                color: '#999', //滚动条颜色
                railOpacity: .3, //滚动条透明度
                disableFadeOut: true, //鼠标经过可滚动区域时显示组件，离开时隐藏组件
                wheelStep: 20, //滚轮滚动量
                alwaysVisible: true, //始终显示组件
                borderRadius: '7px' //滚动条圆角
            });
        },

        /**
         * 审核稿件
         */
        censorManuscript: function() {
            var censorResultType = $("input[name='optionsRadios']:checked", parent.document).val();
            var censorOpinion = $("#auditComments", parent.document).val();
            var casData = JSON.parse(window.localStorage.getItem("login_casData"));
            var cstIsStepback = $("#isStepback").val();
            var postData = {
                mainGuid: mainGuid,
                censorResultType: censorResultType,
                censorOpinion: censorOpinion,
                orgCode: casData.orgCode,
                cstIsStepback : cstIsStepback
            }
            topUtil.ajaxRequest({
                type: "post",
                async: false,
                dataType: "json",
                url: cmedit.global.cmsPath + "CmsController/auditManuscript",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        thisContext.initData();
                        window.parent.cmedit.ManuscriptSystem.initData();
                    } else {
                        console.log(data);
                    }
                }
            });

        },
        
        /**
         * 向融云获取相关推荐文章
         */
        initRongyunRecommond: function() {
            var ue = UE.getEditor("editer_");
            var contentText = ue.getPlainTxt();
            var userColumnIds = window.parent.sessionStorage.getItem(cmedit.global.userColumnIds);
            var recommendHtml = '<img src="../../static/images/831.gif" class="loading_img" alt="" style="text-align: center; margin: 0 auto;display: block;padding-top: 100px;">' +
                '<li style="text-align:center;">正在获取推荐信息，请稍后…</li>';
            $(".recommend_ul").html(recommendHtml);
            var postData = {
                text: contentText,
                userColumnIds: userColumnIds
            }

            topUtil.ajaxRequest({
                type: "post",
                async: true,
                dataType: "json",
                url: cmedit.global.cmsPath + "RonYunController/getRecommend",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        var recommendList = data.data.resources;
                        var html = '';
                        if (recommendList.length > 0) {
                            $(".recommend_nums span").html(data.data.total);
                            var listData = {
                                list: recommendList
                            }
                            html = template('ryRecommendList', listData);
                        } else {
                            html = '<li><p class="noResults">暂无数据</p></li>';
                        }
                        $(".recommend_ul").html(html);
                        $("#pagination").html('');
                    } else {
                        $(".recommend_ul").html("");
                        $("#pagination").html('');
                        $.notify(data.msg);
                    }
                }
            });
        },

        /**
         * 进入稿件详情页
         * @param mainGuid
         * @param mainHeader
         */
        enterManuscript: function(mainGuid, mainHeader) {
            window.parent.cmedit.ManuscriptSystem.enterDetail(mainGuid, mainHeader);
        },
      //-------------------------------------------------新融云相关开始--------------------------------------------

        /**
         * 向融云获取相关推荐文章
         */
        initRongyunRecommond: function() {
            var ue = UE.getEditor("editer_");
            var contentText = ue.getPlainTxt();
            var userColumnIds = window.parent.sessionStorage.getItem(cmedit.global.userColumnIds);
            var recommendHtml = '<img src="../../static/images/831.gif" class="loading_img" alt="" style="text-align: center; margin: 0 auto;display: block;padding-top: 100px;">' +
                '<li style="text-align:center;">正在获取推荐信息，请稍后…</li>';
            $(".recommend_ul").html(recommendHtml);
            var postData = {
                text: contentText,
                userColumnIds: userColumnIds
            }

            topUtil.ajaxRequest({
                type: "post",
                async: true,
                dataType: "json",
                url: cmedit.global.cmsPath + "RonYunController/getRecommend",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        var recommendList = data.data.resources;
                        var html = '';
                        if (recommendList.length > 0) {
                            $(".recommend_nums span").html(data.data.total);
                            var listData = {
                                list: recommendList
                            }
                            html = template('ryRecommendList', listData);
                        } else {
                            html = '<li><p class="noResults">暂无数据</p></li>';
                        }
                        $(".recommend_ul").html(html);
                        $("#pagination").html('');
                    } else {
                        $(".recommend_ul").html("");
                        $("#pagination").html('');
                        $.notify(data.msg);
                    }
                }
            });
        },

        /**
         * 向融云获取原创分析
         */
        initRongyunOriginal: function() {
            var ue = UE.getEditor("editer_");
            var contentText = ue.getPlainTxt();
            var userColumnIds = window.parent.sessionStorage.getItem(cmedit.global.userColumnIds);
            var originalHtml = '</p><ul class="original_ul" ><img style="text-align: center; margin: 0 auto;display: block;padding-top: 100px;" src="../../static/images/831.gif" class="loading_img" alt=""><li style="text-align:center;">正在请求分析…</li></ul>';
            $("#analysisMessage").html(originalHtml);
            var postData = {
                text: contentText,
            }

            topUtil.ajaxRequest({
                type: "post",
                async: true,
                dataType: "json",
                url: cmedit.global.cmsPath + "RonYunController/getOriginalPublic",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        var recommendList = data.data.resources;
                        $("#originalMessage").html("");
                        var html = '';
                        if (recommendList.length > 0) {
                            $(".recommend_nums span").html(data.data.totalCount);
                            var listData = {
                                list: recommendList
                            }
                            html = template('ryArticleListHtml', listData);
                        } else {
                            html = '<li><p class="noResults">暂无数据</p></li>';
                        }
                        $("#analysisMessage").html(html);
                        $("#pagination").html('');
                    } else {
                        $("#analysisMessage").html("");
                        $("#pagination").html('');
                        $.notify(data.msg);
                    }
                }
            });
        },

        /**
         * 向融云获取查重信息
         */
        initRongyunRepetition: function() {
            var ue = UE.getEditor("editer_");
            var contentText = ue.getPlainTxt();
            var userColumnIds = window.parent.sessionStorage.getItem(cmedit.global.userColumnIds);
            var originalHtml = '</p><ul class="original_ul" ><img style="text-align: center; margin: 0 auto;display: block;padding-top: 100px;" src="../../static/images/831.gif" class="loading_img" alt=""><li style="text-align:center;">正在请求分析…</li></ul>';
            $("#analysisMessage").html(originalHtml);
            var postData = {
            	  mainGuid : mainGuid,
                text: contentText,
                userColumnIds: userColumnIds,
                mainType: 0
            }

            topUtil.ajaxRequest({
                type: "post",
                async: true,
                dataType: "json",
                url: cmedit.global.cmsPath + "RonYunController/getOriginalLocal",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        var recommendList = data.data.resources;
                        $("#originalMessage").html("");
                        var html = '';
                        if (recommendList.length > 0) {
                            $(".recommend_nums span").html(data.data.totalCount);
                            var listData = {
                                list: recommendList
                            }
                            html = template('ryRepetitionListHtml', listData);
                        } else {
                            html = '<li><p class="noResults">暂无数据</p></li>';
                        }
                        $("#analysisMessage").html(html);
                        $("#pagination").html('');
                    } else {
                        $("#analysisMessage").html("");
                        $("#pagination").html('');
                        $.notify(data.msg);
                    }
                }
            });
        },

        
        
        /**
         * 插入资源库返回的内容
         * @param XTMessage
         */
        writeXTResourceData: function(XTMessage) {
            var ue = UE.getEditor("ueditor_0");
            if (isNotEmpty(XTMessage)) {
                var XTMessageObj = JSON.parse(XTMessage);
                var sourceList = XTMessageObj.list;
                var callId = XTMessageObj.callId;
                var attachType_noUse = 0;
                var fileNum = 0;
                for (var i = 0; i < sourceList.length; i++) {
                    if (sourceList[i].fileRate == 0) {
                        fileNum++;
                    }
                }
                if (fileNum > 1 && callId.indexOf("litimg") > -1) {
                    window.parent.document.getElementById('iframeXTResource').contentWindow.close();
                    $('#modalXTResource', parent.document).modal('hide');
                    $.notify("上传缩略图只能选择一个文件");
                } else {
                    for (var i = 0; i < sourceList.length; i++) {
                        var attachType = sourceList[i].attachType;
                        var fileRate = sourceList[i].fileRate;
                        if (attachType == 3 || attachType == 1 || attachType == 2 || attachType == 4) {
                            var resourceId = sourceList[i].resourceId;
                            var resourceAddr = sourceList[i].resourceAddr;
                            var resourceName = sourceList[i].resourceName;
                            var resourceVirtualId = sourceList[i].resourceVirtualId;
                            var bigIcon = sourceList[i].bigIcon;

                            if (fileRate == 0) { //只要原码图
                                //插入正文
                                if (callId.indexOf("main") > -1) {
                                    //向附件表中插入记录
                                    thisContext.uploadAttachment(attachType, resourceId, resourceAddr, resourceName, 0);
                                    thisContext.insertXTLink(attachType,resourceVirtualId, sourceList,bigIcon);
//                                    thisContext.insertXTLink(attachType, resourceId, resourceAddr, resourceName, fileRate);
                                    //插入缩略图
                                } else if (callId.indexOf("litimg") > -1) {
                                    if (attachType != 1) {
                                        window.parent.document.getElementById('iframeXTResource').contentWindow.close();
                                        $('#modalXTResource', parent.document).modal('hide');
                                        $.notify('只能选择图片文件作为缩略图!');
                                    } else {
                                        //向附件表中插入记录
                                        thisContext.uploadAttachment(attachType, resourceId, resourceAddr, resourceName, 0);
                                        thisContext.uploadLitimg(resourceAddr);
                                    }
                                }
                            }
                        } else {
                            attachType_noUse++;
                        }
                    }
                }
                if (sourceList.length != 0 && attachType_noUse == sourceList.length) {
                    window.parent.document.getElementById('iframeXTResource').contentWindow.close();
                    $('#modalXTResource', parent.document).modal('hide');
                    $.notify('只能选择图片文件作为缩略图!');
                }
            }
        },
        /**
         * 编辑器里图片点击事件
         * @param 
         */
        imgClickEvent: function(img) {
            $(".cont_right>div").not(".messagetabs").hide();
            var ue = UE.getEditor("editer_");
            var thisImg = $(img),
                description = thisImg.attr("description"),
                address = thisImg.attr("src"),
                name = thisImg.attr("alt"),
                originalWidth = thisImg.width(),
                originalHeight = thisImg.height();
            var imagePreview = '<img src="' + address + '" alt="' + name + '" style="width: 100%; height: 100%;">';
            $('#imgAddress').val(address);
            $('#imgName').val(name);
            $('#imgDescribe').val("");
            if (description) {
                $('#imgDescribe').val(description);
            }
            thisImg.attr("title", name);
            //判断图片来源
            if (typeof(thisImg.attr("cfbresourceid")) != "undefined") {
                $("#image_original").html("本地资源");
            } else if (typeof(thisImg.attr("fileid")) != "undefined") {
                $("#image_original").html("<span style='color:#C93111;' >媒资系统(CRE)</span>");
            } else {
                $("#image_original").html("网络资源");
            }
            $('#image_preview').html(imagePreview);
            $('#back_to_original').off("click").on("click", function() {
                $('#img_width').val(originalWidth);
                $('#img_height').val(originalHeight);
                thisImg.width(originalWidth);
                thisImg.height(originalHeight);
            });
            $('#back_to_original').trigger("click");
            // 设置尺寸
            var ratio = $('#img_width').val() / $('#img_height').val();
            $('#image_size_lock').off("click").on("click", function() {
                $(this).children().toggleClass("icon-suo icon-jiesuo");
                ratio = $('#img_width').val() / $('#img_height').val();
                if ($(this).children().hasClass("icon-suo")) {
                    $('#lock_explain').html("已锁定比例");
                } else {
                    $('#lock_explain').html("已解锁比例");
                }
            });
            $('#img_width').off("input").on("input", function() {
                var imgSize = $(this).val();
                thisImg.width(imgSize);
                if ($('#image_size_lock').children().hasClass("icon-suo")) {
                    var newSize = parseInt(imgSize / ratio);
                    $('#img_height').val(newSize);
                    thisImg.height(newSize);
                }
            });
            $('#img_height').off("input").on("input", function() {
                var imgSize = $(this).val();
                thisImg.height(imgSize);
                if ($('#image_size_lock').children().hasClass("icon-suo")) {
                    var newSize = parseInt(imgSize * ratio)
                    $('#img_width').val(newSize);
                    thisImg.width(newSize);
                }
            });
            // 名称
            $('#imgName').off("change").on("change", function() {
            	var name = $(this).val();
                thisImg.attr("alt", name);
                thisImg.attr("title", name);
                $('#imgName').val(name);
            });
            // 描述
            $('#imgDescribe').off("change").on("change", function() {
            	var context = $(this).val();
            	thisImg.attr("description", context);
            });
            //设置浮动
            $('#float_none').on("click", function() {
                ue.execCommand('imagefloat', 'none');
            });
            $('#float_left').on("click", function() {
                ue.execCommand('imagefloat', 'left');
            });
            $('#float_right').on("click", function() {
                ue.execCommand('imagefloat', 'right');
            });
            $('#float_middle').on("click", function() {
                ue.execCommand('imagefloat', 'center');
            });
            //设置缩略图
            $('#set_thumbnail_btn').on("click", function() {
                thisContext.uploadLitimg(address);
            });
            //编辑图片
            $('#edit_image_btn').on("click", function() {
                ue.execCommand("waterimage", address);
            });
            $('#imageProperty').show();
        },
        
        /**
         * 插入cre资源
         * @param attachmentList
         */
        writeCREResourceData: function(attachmentList) {
            var ue = UE.getEditor("editer_");
            for (var i = 0; i < attachmentList.length; i++) {
            	var attachHtml = '';
                var attachment = attachmentList[i];
                var resourceAddr = attachment.resourceAddr;
                var attachType = attachment.attachType;
                var resourceId = attachment.resourceId;
                var resourceName = attachment.resourceName;
                if (attachType == 'picture') {
                    attachType = 1;
                    // 附件为图片
                    attachHtml += '<img cbbvresourceid="'+resourceId+'" fileid="' +
                        resourceId + '" src="' +
                        resourceAddr +
                        '" alt="' + resourceName + '"/>';
                } else if (attachType == 'audio') {
                    attachType = 3;
                    // 附件为音频
                    attachHtml += '<p><span style="color: rgb(89, 89, 89); font-size: 20px;"><strong><span style="color: rgb(89, 89, 89); font-family: 微软雅黑, &#39;Microsoft YaHei&#39;;"></span></strong></span>' +
                        '<audio cbbvresourceid="'+resourceId+'" fileid="' +
                        resourceId +
                        '" id="media" src="' +
                        resourceAddr +
                        '" alt="' + resourceName + '" controls=""/></p ><p><br/></p >';
                } else if (attachType == 'video') { // 视频
                    attachType = 2;
                    attachHtml += '<img/><video cbbvresourceid="'+resourceId+'" fileid="' +
                        resourceId +
                        '" class="edui-upload-vio  vjs-default-skin video-js" controls="true" controlslist="nodownload" preload="metadata" src="' +
                        resourceAddr +
                        '" data-setup="{}"> ' +
                        '<source cbbvresourceid="'+resourceId+'" fileid="' +
                        resourceId + '" src="' +
                        resourceAddr +
                        '" alt="' + resourceName + '" type="video/mp4"/>' +
                        '<p><br/></p >';
                }
                thisContext.uploadAttachment(attachType, resourceId, resourceAddr, resourceName, 1);
                ue.execCommand('insertHtml', attachHtml);
            }
            //            	ue.setContent(attachHtml,true);  //插入文件末尾
            //关闭当前窗口
            window.parent.cmedit.ManuscriptSystem.closeCREModalWindow();
        },

        /**
         * 插入蓝云资源
         * @param attachmentList
         */
        writeLANResourceData: function(attachmentList) {
        	var attachHtml = '';
        	var ue = UE.getEditor("editer_");
        	for (var i = 0; i < attachmentList.length; i++) {
        		var attachment = attachmentList[i];
        		var resourceAddr = attachment.resourceAddr;
        		var attachType = attachment.attachType;
        		var resourceId = attachment.resourceId;
        		var resourceName = attachment.resourceName;
        		//上传附件资源到
        		var attachTypeInt;
        		
        		
        		if (attachType == 'picture') {
        			// 附件为图片
        			attachTypeInt = 1;
        			attachHtml += '<img fileid="' +
        			resourceId + '" src="' +
        			resourceAddr +
        			'" alt="' + resourceName + '"/>';
        		} else if (attachType == 'audio') {
        			// 附件为音频
        			attachTypeInt = 3;
        			attachHtml += '<p><span style="color: rgb(89, 89, 89); font-size: 20px;"><strong><span style="color: rgb(89, 89, 89); font-family: 微软雅黑, &#39;Microsoft YaHei&#39;;"></span></strong></span>' +
        			'<audio fileid="' +
        			resourceId +
        			'" id="media" src="' +
        			resourceAddr +
        			'" alt="' + resourceName + '" controls=""/></p ><p><br/></p >';
        		} else if (attachType == 'video') { // 视频
        			attachTypeInt = 2;
        			attachHtml += '<img/><video fileid="' +
        			resourceId +
        			'" class="edui-upload-vio  vjs-default-skin video-js" controls="true" controlslist="nodownload" preload="metadata" src="' +
        			resourceAddr +
        			'" data-setup="{}"> ' +
        			'<source fileid="' +
        			resourceId + '" src="' +
        			resourceAddr +
        			'" alt="' + resourceName + '" type="video/mp4"/>' +
        			'<p><br/></p >';
        		}
        		thisContext.uploadAttachment(attachTypeInt, resourceId, resourceAddr, resourceName, 1);
        	}
        	ue.execCommand('insertHtml', attachHtml);
        	//            	ue.setContent(attachHtml,true);  //插入文件末尾
        	//关闭当前窗口
        	window.parent.cmedit.ManuscriptSystem.closeLANModalWindow();
        },
		/**
         * 插入大观资源
         * @param attachmentList
         */
        writeDGResourceData: function(attachmentList) {
         	var attachHtml = '';
         	var ue = UE.getEditor("editer_");
         	for (var i = 0; i < attachmentList.length; i++) {
         		var attachment = attachmentList[i];
         		var resourceAddr = attachment.resourceAddr;
         		var attachType = attachment.attachType;
         		var resourceId = attachment.resourceId;
         		var resourceName = attachment.resourceName;
         		//上传附件资源到
         		var attachTypeInt;
         		
         		
         		if (attachType == 2) {
         			// 附件为图片
         			attachTypeInt = 1;
         			attachHtml += '<img fileid="' +
         			resourceId + '" src="' +
         			resourceAddr +
         			'" alt="' + resourceName + '"/>';
         		} else if (attachType == 3) {
         			// 附件为音频
         			attachTypeInt = 3;
         			attachHtml += '<p><span style="color: rgb(89, 89, 89); font-size: 20px;"><strong><span style="color: rgb(89, 89, 89); font-family: 微软雅黑, &#39;Microsoft YaHei&#39;;"></span></strong></span>' +
         			'<audio fileid="' +
         			resourceId +
         			'" id="media" src="' +
         			resourceAddr +
         			'" alt="' + resourceName + '" controls=""/></p ><p><br/></p >';
         		} else if (attachType == 1) { // 视频
         			attachTypeInt = 2;
         			attachHtml += '<img/><video fileid="' +
         			resourceId +
         			'" class="edui-upload-vio  vjs-default-skin video-js" controls="true" controlslist="nodownload" preload="metadata" src="' +
         			resourceAddr +
         			'" data-setup="{}"> ' +
         			'<source fileid="' +
         			resourceId + '" src="' +
         			resourceAddr +
         			'" alt="' + resourceName + '" type="video/mp4"/>' +
         			'<p><br/></p >';
         		}
         		thisContext.uploadAttachment(attachTypeInt, resourceId, resourceAddr, resourceName, 1);
         	}
         	ue.execCommand('insertHtml', attachHtml);
         	//            	ue.setContent(attachHtml,true);  //插入文件末尾
         	//关闭当前窗口
         	window.parent.cmedit.ManuscriptSystem.closeDGModalWindow();
        },
        /**
         * 打开资源库窗口上传缩略图
         */
        uploadLitimgByCFB: function() {
            if (!topUtil.isNotEmpty(mainGuid)) {
                thisContext.saveManuscript("auto");
            }
            var cbbvFlag = creCbbvFlag == "1" ? true : false;  
            var url = window.top.sessionStorage.getItem("CFBExternalUrl");
            var type = "litimg_";
            if(cbbvFlag) {   //蓝鲸资源库
                url = window.location.href.substring(0, window.location.href.indexOf(cmedit.global.appName));
                url += cmedit.global.PUB_PORTAL_CODE + "static/plugins/CBBV/views/cbbv_manager.html"+
                "?userid=" + userId +
                '&userName=' + userName +
                '&tenantId=' + tenantId +
                '&token=' + token +
                '&callId='+ type + mainGuid +
                '&attachType=' + '4'+
                '&callBack=' + 'window.parent.cmedit.ManuscriptSystem.cbbvResourceBack';
            } else {  //文件库
                url += '?userid=' + userId +
                '&userName=' + userName +
                '&token=' + token +
                '&tenantId=' + tenantId +
                '&callId=' + type + mainGuid +
                '&attachType=' + '4';
            }
           
            //window.top.tipsWindown("资源库", "iframe:"+url,"1200", "600", "true", "", "true", "text");


            //$('#iframeXTResource',window.top.document).attr('src','http://127.0.0.1:8028/dycfbweb/views/main/external.html?userid=0003&userName=0003-禁止删除用户用于系统间联调&token=TGT-2181-syb0U2VIQACmhLYYFwqgU0VSxFfRcV1ATDqmpFtKFdu0lOKawo-cas&tenantId=dayang.com');
            $('#iframeXTResource', window.top.document).attr('src', url);
            $('#modalXTResource', window.top.document).modal('show');
        },
        //蓝鲸挂接资源回调处理
        cbbvResourceBack: function(XTMessageObj) {
            var ue = UE.getEditor("ueditor_0");
            if (isNotEmpty(XTMessageObj)) {
                // var XTMessageObj = JSON.parse(XTMessage);
                var sourceList = XTMessageObj.attachments;
                var callId = XTMessageObj.callId;
                var attachType_noUse = 0;
                var fileNum = 0;
                for (var i = 0; i < sourceList.length; i++) {
                    if (sourceList[i].attachType == 'IMAGE') {
                        fileNum++;
                    }
                }
                if (fileNum > 1 && callId.indexOf("litimg") > -1) {
                    thisContext.closeCbbvModalWindow();
                    $.notify("上传缩略图只能选择一个文件");
                } else {
                    for (var i = 0; i < sourceList.length; i++) {
                        var attachType = sourceList[i].attachType;
                        // var fileRate = sourceList[i].fileRate;
                        if (attachType == "IMAGE" || attachType == "AUDIO" || attachType == "VIDEO") {
                            var resourceId = sourceList[i].resourceId;
                            var resourceAddr = sourceList[i].resourceAddr;
                            var resourceName = sourceList[i].resourceName;
                            var resourceVirtualId = sourceList[i].resourceVirtualId;
                            attachType = thisContext.changeFileType(attachType);
                            // if (fileRate == 0) { //只要原码图
                                //插入正文
                                if (callId.indexOf("main") > -1) {
                                    //向附件表中插入记录
                                    thisContext.uploadAttachment(attachType, resourceId, resourceAddr, resourceName, 0);
//                                    thisContext.insertXTLink(attachType, resourceId, resourceAddr, resourceName, fileRate);
                                    thisContext.insertXTLink(attachType,resourceVirtualId, sourceList);
                                    //插入缩略图

                                } else if (callId.indexOf("litimg") > -1) {
                                    if (attachType != '1') {
                                        window.parent.document.getElementById('iframeXTResource').contentWindow.close();
                                        $('#modalXTResource', parent.document).modal('hide');
                                        $.notify('只能选择图片文件作为缩略图!');
                                    } else {
                                        //向附件表中插入记录
                                        thisContext.uploadAttachment(attachType, resourceId, resourceAddr, resourceName, 0);
                                        thisContext.uploadLitimg(resourceAddr);
                                    }
                                }
                            // }
                        } else {
                            attachType_noUse++;
                        }
                    }
                }
                if (sourceList.length != 0 && attachType_noUse == sourceList.length) {
                    thisContext.closeCbbvModalWindow();
                    $.notify('只能选择图片文件作为缩略图!');
                }
            }
            
        },
        changeFileType: function(attachType) {
            if (attachType == "IMAGE") {
                return 1;
            } else if (attachType == "VIDEO") {
                return 2;
            } else if (attachType == "AUDIO") {
                return 3;
            } else if ("DOCUMENT") {
                return 5;
            } else {
                return "OTHER";
            }
        },
        closeCbbvModalWindow: function() {
            // $('#modalXTResource', window.top.document).modal('hide');
            //关闭iframe弹框
           /*  $("#windownbg", window.top.document).remove();
            $("#windown-box", window.top.document).remove(); */
            window.parent.document.getElementById('iframeXTResource').contentWindow.close();
            $('#modalXTResource', parent.document).modal('hide');
        },
        /**
         * 上传附件
         * @param attachType
         * @param resourceId
         * @param resourceAddr
         * @param resourceName
         * @param fileRate
         */
        uploadAttachment: function(attachType, resourceId, resourceAddr, resourceName, fileRate) {
            var postData = {
                maFilePath: resourceAddr,
                maFileName: resourceName,
                maFileType: attachType,
                muaQuoteType: 0,
                muaRequestId: resourceId,
                mainGuid: mainGuid
            }

            topUtil.ajaxRequest({
                type: "post",
                async: false,
                dataType: "json",
                url: cmedit.global.cmsPath + "ManuscriptAttachmentController/addManuscriptAttachment",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        thisContext.initAttachment();
                        $.notify("资源信息插入成功");
                    } else {
                        $.notify(data.msg);
                    }
                }
            });

        },

        /**
         * 上传本地图片到缩略图
         */
        uploadLocalLitimg: function() {
            var reader = new FileReader();
            var file = $("#litimg_file")[0].files[0];
            var imgUrlBase64 = '';
            var fileAllName;
            var fileNameArr;
            var imgSuffix;
            if (file) {
                //将文件转换为base64
                reader.readAsDataURL(file);
                reader.onload = function(e) {
                    var strFilter = ".jpeg|.gif|.jpg|.png|.bmp|.pic|";

                    imgUrlBase64 = e.target.result.substring(22);
                    fileAllName = file.name;
                    var index = fileAllName.lastIndexOf("\.");
                    imgSuffix = fileAllName.substring(index + 1, fileAllName.length);
                    if (strFilter.indexOf(imgSuffix) > -1) {
                        var imgArray = new Array();
                        var imgObj = {
                            imgBase64: imgUrlBase64,
                            imgSuffix: imgSuffix,
                            fileName: fileAllName
                        };
                        imgArray.push(imgObj);
                        var mainGuid = $("#mainGuid").val();
                        var postData = {
                            mainGuid: mainGuid,
                            images: JSON.stringify(imgArray)
                        };
                        /**
                         * 上传图片
                         */
                        topUtil.ajaxRequest({
                            async: false,
                            url: cmedit.global.cmsPath + "/UploadController/uploadImage",
                            type: 'POST',
                            data: postData,
                            dataType: 'json',
                            success: function(data) {
                                if (data.status == true || data.status == "true") {
                                    var imgList = data.data;
                                    var img_width, img_height;
                                    $("#litimgPriview").attr('src', imgList[0].streamPath);
                                    $("#litimgAddr").val(imgList[0].streamPath);
                                    $("#shotPicLitimg").html('<img src="' + imgList[0].streamPath + '">');
                                    thisContext.initAttachment();
                                } else {
                                    $.notify(data.msg);
                                }
                            }
                        });
                    } else {
                        $.notify("文件不是图片，请重新选择！");
                    }

                };

            } else {

            }
        },

        /**
         * 上传缩略图实际操作
         */
        uploadLitimg: function(resourceAddr) {
            var imgHtml = '<img  src="' + resourceAddr + '">' +
                '<div class="upLoadEdit">' +
                '<i class="iconfont icon-bianji" title="修改" onclick="cmedit.EditSystem.uploadLitimgByCFB()"></i>' +
                '<i class="iconfont icon-shanchu5" title="删除" onclick="cmedit.EditSystem.deleteLitimg()"></i>' +
                '</div>';
            $(".uploadImg").html(imgHtml);
            $(".uploadImg").show();
            $(".upLoadBtn").hide();
            $.notify("设置成功");
            //$("#litimgPriview").attr('src',resourceAddr);
            $("#shotPicLitimg").html('<img src="' + resourceAddr + '">');
            $("#litimgAddr").val(resourceAddr);
            //关闭当前窗口
            window.parent.document.getElementById('iframeXTResource').contentWindow.close();
            $('#modalXTResource', parent.document).modal('hide');
        },
        /**
         * 删除缩略图
         */
        deleteLitimg: function() {
            var imgHtml = '';
            $(".uploadImg").html(imgHtml);
            $(".uploadImg").hide();
            $(".upLoadBtn").show();
            $("#litimgAddr").val("");
            $.notify("缩略图删除成功！");
        },
        /**
         * 删除缩略图
         */
        deleteLitimg: function() {
            var imgHtml = '';
            $(".uploadImg").html(imgHtml);
            $(".uploadImg").hide();
            $(".upLoadBtn").show();
            $("#litimgAddr").val("");
            $.notify("缩略图删除成功！");
        },
        /**
         * 验证标题字数
         * @param obj
         * @param maxlength
         * @param id
         */
        setShowLengthWebPage: function(obj, maxlength, id) {
            var rem = maxlength - obj.value.length;
            var wid = id;
            if (rem < 0) {
                rem = 0;
            } else if (rem > 0 && rem <= maxlength) {
                /* document.getElementById(wid).style.display = "";
                document.getElementById(wid).value = "还可以输入" + rem + "字数"; */
            } else {
                $.notify("标题内容最多可输入" + maxlength + "个字符");
                /* 	document.getElementById(wid).value=""; 
                	document.getElementById(wid).style.display = "none"; */
            }
        },
        // 设计-美图秀秀
        designBymeituxx: function(imagepath) {
            var manuscriptid = $("#mainGuid").val();
            var editor = UE.getEditor("editer_");

            var dialog = new UE.ui.Dialog({
                iframeUrl: window.top.location.href.substring(0, window.location.href.indexOf("dywebpageweb")) + 'dywebpageweb/static/plugins/ueditor/dialogs/meituxiuxiu/meituxx.html?imagepath=' + imagepath + '&manuscriptid=' + manuscriptid, //meituxx.html页面
                editor: editor,
                name: "meituxiuxiuname",
                title: "美图秀秀"
            });
            dialog.fullscreen = true;
            dialog.draggable = false;
            dialog.render();
            dialog.open();
        },

        //从文件库插入
        insertXTLink: function(attachType, resourceVirtualId,sourceList,bigIcon) {
            var ue = UE.getEditor("editer_");
            var resourceId = "";//原码id
            var resourceName = "";//原码名称
            var resourceAddr = "";//原码地址
            var cutResourceId = "";//压缩之后id
            var cutResourceName = "";//压缩之后名称
            var cutResourceAddr = "";//压缩之后地址
            var isCut = true;
            sourceList.forEach(function(source){
            	//保证是同一个文件
            	if(resourceVirtualId == source.resourceVirtualId){
            		//原码
            		if(source.fileRate == 0){
            			resourceId = resourceVirtualId;
            			resourceName = source.resourceName;
            			resourceAddr = source.resourceAddr;
            		}else if(source.fileRate == 1){
            			cutResourceId = resourceVirtualId;
            			cutResourceName = source.resourceName;
            			cutResourceAddr = source.resourceAddr;
            			isCut = false;
                    }
                    if(source.fileRate == undefined){
                        resourceId = resourceVirtualId;
	            		resourceName = source.resourceName;
	            		resourceAddr = source.resourceAddr;
                    }
            	}
            })
            if(isCut && attachType == 2){// 如果为视频资源，需判断是否有源码文件夹
            	$.notify("检测到引用资源中存在未转码资源，可能无法预览！");
            }
            if(!topUtil.isNotEmpty(cutResourceId)){
            	cutResourceId = resourceId;
            	cutResourceAddr = resourceAddr;
            }
            // 拼装附件html
            var attachHtml = "";
            //视频:0 音频:1 图片:2
            if (attachType == 1) { // 图片
                attachHtml = '<img CFBBaseResourceId="' +
                	resourceId + '" src="' +
                	resourceAddr
                    //		    				+ '" style="width:600px;height:600px;" alt="'
                    +
                    '"  alt="' +
                    resourceName + '"></img>';
            } else if (attachType == 3) { // 音频
                attachHtml = '<p><span style="color: rgb(89, 89, 89); font-size: 20px;"><strong><span style="color: rgb(89, 89, 89); font-family: 微软雅黑, &#39;Microsoft YaHei&#39;;"></span></strong></span>' +
                    '<audio CFBBaseResourceId="' +
                    resourceId +
                    '" src="' +
                    resourceAddr +
                    '" controls=""></audio></p><p><br/></p>';
            } else if (attachType == 2 || attachType == 4) { // 视频
                attachHtml = '<img/><video poster= "'+bigIcon+'" CFBBaseResourceId="'+resourceId+'" CFBBaseResourceSrc="'+resourceAddr+'" CFBResourceId="' +
                	cutResourceId +
                    '" controls="true" controlslist="nodownload" preload="metadata"  src="' //width="420" height="280"
                    +
                    cutResourceAddr +
                    '" data-setup="{}"> ' +
                    '<source CFBBaseResourceId="'+resourceId+'" CFBBaseResourceSrc="'+resourceAddr+'" CFBResourceId="' +
                    cutResourceId + '" src="' +
                    cutResourceAddr +
                    '" type="video/mp4"/>' +
                    '</video><p><br/></p>';
            }
            ue.execCommand('insertHtml', attachHtml);
            //关闭当前窗口
            window.parent.document.getElementById('iframeXTResource').contentWindow.close();
            $('#modalXTResource', parent.document).modal('hide');
        },
        
        //从参考资源插入
        insertXTLinkReference: function(attachType, resourceId,resourceAddr,resourceName) {
        	var ue = UE.getEditor("editer_");
        	var cutResourceId = resourceId;//压缩之后id
        	var cutResourceAddr = resourceAddr;//压缩之后地址
        	// 拼装附件html
        	var attachHtml = "";
        	//视频:0 音频:1 图片:2
        	if (attachType == 1) { // 图片
        		attachHtml = '<img CFBResourceId="' +
        		resourceId + '" src="' +
        		resourceAddr
        		//		    				+ '" style="width:600px;height:600px;" alt="'
        		+
        		'"  alt="' +
        		resourceName + '"></img>';
        	} else if (attachType == 3) { // 音频
        		attachHtml = '<p><span style="color: rgb(89, 89, 89); font-size: 20px;"><strong><span style="color: rgb(89, 89, 89); font-family: 微软雅黑, &#39;Microsoft YaHei&#39;;"></span></strong></span>' +
        		'<audio CFBResourceId="' +
        		resourceId +
        		'" src="' +
        		resourceAddr +
        		'" controls=""></audio></p><p><br/></p>';
        	} else if (attachType == 2 || attachType == 4) { // 视频
        		attachHtml = '<img/><video CFBBaseResourceId="'+resourceId+'" CFBBaseResourceSrc="'+resourceAddr+'" CFBResourceId="' +
        		cutResourceId +
        		'" controls="true" controlslist="nodownload" preload="metadata"  src="' //width="420" height="280"
        		+
        		cutResourceAddr +
        		'" data-setup="{}"> ' +
        		'<source CFBBaseResourceId="'+resourceId+'" CFBBaseResourceSrc="'+resourceAddr+'" CFBResourceId="' +
        		cutResourceId + '" src="' +
        		cutResourceAddr +
        		'" type="video/mp4"/>' +
        		'</video><p><br/></p>';
        	}
        	ue.execCommand('insertHtml', attachHtml);
        },

        /**
         * 删除附件
         * @param maGuid
         */
        deleteAttachment: function(maGuid) {
            var postData = {
                maGuid: maGuid
            }
            topUtil.ajaxRequest({
                type: "post",
                async: false,
                dataType: "json",
                url: cmedit.global.cmsPath + "ManuscriptAttachmentController/deleteManuscriptAttachment",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        thisContext.initAttachment();
                        $.notify("删除附件信息成功");
                    } else {
                        $.notify(data.msg);
                    }
                }
            });
        },

        /**
         * 稿件预览【手机格式】
         */
        webPreview: function() {
            $('#manuscriptPreview_web', window.top.document).css('display', 'block');
            $('#manuscriptPreview_weixin', window.top.document).css('display', 'none');
            $("body", window.top.document).attr("class", "modal-open");
            /*$("#manuscriptPreview",window.top.document).attr("aria-hidden", "false");
            $("#manuscriptPreview",window.top.document).attr("class", "modal fade in");
            $("#manuscriptPreview",window.top.document).attr("style", "display:block;top: 50px;");*/
            window.parent.cmedit.ManuscriptSystem.showMobilePreview();
            $("#modal-backdrop", window.top.document).attr("class", "modal-backdrop fade in");
            var header = $('#edit_title').val(); //标题
            //            	var username = $("#mainAuthor").val(); //作者
            var username = $("#mainCreateUserName").val(); //作者
            var createtime = $('#cmsCreateTime').val(); //创建时间
            if (topUtil.isNotEmpty(createtime)) {
                createtime = createtime.substring(0, 11);
            }
            var ue = UE.getEditor("editer_");
            var content = ue.getContent();
            $('#manuscriptPreview h1[name="title"]', window.top.document).html(header);
            $('#manuscriptPreview span[name="createtime"]', window.top.document).html(createtime);
            $('#manuscriptPreview span[name="username"]', window.top.document).html(username);
            $('#manuscriptPreview div[name="webContent"]', window.top.document).addClass("vid-wrapper");
            $('#manuscriptPreview div[name="webContent"]', window.top.document).html(content);
            //图片宽度自适应
            $('#manuscriptPreview div[name="webContent"]', window.top.document).find("img").css("width","100%").css("height","100%");
            // 设置默认宽度为360
            window.top.cmedit.ManuscriptSystem.setPhoneSize(360);
            $('#manuscriptPreview div[name="webContent"] p img', window.top.document).load(function() {
                if (!$(this).attr("data-width") && !$(this).attr("data-wxsrc") && !$(this).attr("data-id")) {
                    if ($(this).width() > 319) {
                        window.top.cmedit.ManuscriptSystem.setWidthHeight(this);
                    }
                }
            });
            $('#manuscriptPreview div[name="webContent"] p img', window.top.document).error(function() {
                window.top.cmedit.ManuscriptSystem.getFail(this);
            });
            $('#manuscriptPreview div[name="webContent"] section[class="_135editor"]', window.top.document).each(function() {
                $(this).find('section').eq(0).css('width', '100%');
            });
            $('#setPhoneSize_360', window.top.document).attr('onClick', "window.top.cmedit.ManuscriptSystem.setPhoneSize(360)");
            $('#setPhoneSize_320', window.top.document).attr('onClick', "window.top.cmedit.ManuscriptSystem.setPhoneSize(320)");
            window.top.cmedit.ManuscriptSystem.wechatShow(mainGuid);
        },

        /**
         * 检查输入框字数
         * @param word
         */
        checkWordLength: function(word) {
            var maxLength = parseInt(word.attr("maxLength"));
            var realLength = word.val().length;
            if (realLength == maxLength) {
                $.notify("已达到最大长度，不能再输入了！");
            }
        },

        /**
         * 隐藏模态窗口
         * 
         */
        hideMyModal: function(divId, HJFlag) {
            $("#externalSystemLoginTag", window.top.document).val("");
            $("textarea[name='censorOpinion']", window.top.document).val("");
            $("body", window.top.document).attr("class", "");
            $("#modal-backdrop", window.top.document).attr("class", "");
            $("#" + divId, window.top.document).attr("aria-hidden", "true");
            $("#" + divId, window.top.document).attr("class", "modal fade");
            $("#" + divId, window.top.document).attr("style", "display:");
            if (HJFlag == true) {
                window.localStorage.removeItem("HJMessage");
            }
        },
        /**
         * 设置图片宽高
         * @param ImgD
         */
        setWidthHeight: function(ImgD) { //参数(图片,允许的宽度,允许的高度)
            var iheight = 2000;
            var iwidth = $('#manuscriptPreview div[name="webContent"]', window.top.document).outerWidth();
            var src = $(ImgD).attr("src");
            var imgwidth = 0;
            var imgheight = 0;
            if (imgList[src] == null) {
                imgwidth = $(ImgD).outerWidth();
                imgheight = $(ImgD).outerHeight();
                imgList[src] = imgwidth + "," + imgheight;
            } else {
                var wh = imgList[src].split(",");
                imgwidth = wh[0];
                imgheight = wh[1];

            }
            if (imgwidth > 0 && imgheight > 0) {
                if (imgwidth / imgheight >= iwidth / iheight) {
                    if (imgwidth > iwidth) {
                        //	        				   $(ImgD).attr("style", "width:"+iwidth+";height:"+((imgheight*iwidth)/imgwidth)+"px");
                        $(ImgD).attr("width", iwidth + "px");
                        $(ImgD).attr("height", ((imgheight * iwidth) / imgwidth) + "px");
                    } else {
                        //	        				   $(ImgD).attr("style", "width:"+imgwidth+"px;height:"+imgheight+"px");
                        $(ImgD).attr("width", imgwidth + "px");
                        $(ImgD).attr("height", imgheight + "px");
                    }
                } else {
                    if (imgheight > iheight) {
                        //	        				   $(ImgD).attr("style", "width:"+((imgwidth*iheight)/imgheight)+"px;height:"+iheight+"px");
                        $(ImgD).attr("width", ((imgwidth * iheight) / imgheight) + "px");
                        $(ImgD).attr("height", iheight + "px");
                    } else {
                        //	        				   $(ImgD).attr("style", "width:"+imgwidth+"px;height:"+imgheight+"px");
                        $(ImgD).attr("width", imgwidth + "px");
                        $(ImgD).attr("height", imgheight + "px");
                    }
                }
            }
        },

        /**
         * 获取当前页面中ueditor的内容
         */
        getEditorContent: function() {
            var ue = UE.getEditor("editer_");
            var content = ue.getContent();
            return content;
        },

        /**
         * 获取当前页的稿件信息
         * @returns
         */
        getHeadContent: function() {
            var mainHeader = $('#edit_title').val();
            var mainColumnId = $('#preReportColumn').val();
            var mainIsOriginal = $('#mainIsOriginal').val();
            var mainSources = $('#mainSources').val();
            var mainFolderName = $('#selectInput').selectPageText();
            //                var mainAuthor = $("#mainAuthor").val() == "未选取"?"":$("#mainAuthor").val();
            var mainAuthor = $('#mainAuthor').val();
            var mainCorrespondent = $('#mainCorrespondent').val();
            var cmsSubtitle = $('#cmsSubtitle').val();
            var mainSummary = $('#mainSummary').val();
            var cmsSourceUrl = $('#cmsSourceUrl').val();
            var mainKeyWords = $('#mainKeyWords').val();
            var cmsLowImage = $('#litimgAddr').val();
            var headContent = mainHeader + mainIsOriginal + mainColumnId + mainSources +
                mainFolderName + mainAuthor +mainCorrespondent+
                cmsSubtitle + mainSummary + cmsSourceUrl +
                mainKeyWords + cmsLowImage;
            return headContent;
        },


        /**
         * word导入
         * 
         * @param manuscriptid
         */
        importWord: function() {
            $("input[name='word_manuscriptid']").val(mainGuid);
            $("#word_file").click();
        },

        /**
         * 插入音频
         * 
         * @param manuscriptid
         */
        insertAudio: function(manuscriptid) {
            $("input[name='audio_manuscriptid']").val(manuscriptid);
            $("#audio_file").click();
        },
        boxStyle: function() {
            $(".res-listbox").show();
            $(".res-listline").hide();
            $(".icon-datumoshi").addClass("show_style_color")
            $(".icon-liebiaomoshi").removeClass("show_style_color")
        },
        lineStyle: function() {
            $(".res-listbox").hide();
            $(".res-listline").show();
            $(".icon-liebiaomoshi").addClass("show_style_color")
            $(".icon-datumoshi").removeClass("show_style_color")
        },

        //-------------------------------------------------融之联相关开始---------------------------------------------
        /**
         * 向融之联(分页)查询相关推荐文章
         */
        initRonglianCommend: function(currentPage) {
            var mainGuid = $("#mainGuid").val();
            clearTimeout(similarityTimer); //关闭定时器
            var recommendHtml = '<img src="../../static/images/831.gif" class="loading_img" alt="" style="text-align: center; margin: 0 auto;display: block;padding-top: 100px;">' +
                '<li style="text-align:center;">正在获取推荐信息，请稍后…</li>';
            $(".recommend_ul").html(recommendHtml);
            $(".cont_right>div").not(".messagetabs").hide();
            $(".resource_recommend").show();
            var mainGuid = $("#mainGuid").val();
            var ue = UE.getEditor("editer_");
            var contentText = ue.getPlainTxt();
            var postData = {
                mainGuid: mainGuid,
                start: currentPage,
                text: contentText
            }
            topUtil.ajaxRequest({
                type: "post",
                async: true,
                dataType: "json",
                url: cmedit.global.cmsPath + "RongZhiLianController/getRecommend",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        var recommendList = data.data.list;
                        var html = '';
                        if (recommendList.length > 0) {
                            $(".recommend_nums span").html(data.data.totalCount);
                            var listData = {
                                list: recommendList
                            }
                            html = template('recommendList', listData);
                        } else {
                            html = '<li><p class="noResults">暂无数据</p></li>';
                        }
                        $(".recommend_ul").html(html);
                        $("#pagination").html('');
                        thisContext.initPage(data.data.totalPage);
                        if (!currentPage) {
                            $('#pagination').whjPaging('setPage', 1, data.data.totalPage);
                        }
                    } else {
                        $(".recommend_ul").html("");
                        $.notify(data.msg);
                    }
                }
            });
        },

        /**
         * 初始化分页数据
         */
        initPage: function() {
            $("#pagination").whjPaging({
                pageSizeOpt: [
                    { 'value': 5, 'text': '5条/页', 'selected': true },
                    { 'value': 10, 'text': '10条/页' },
                    { 'value': 15, 'text': '15条/页' },
                    { 'value': 20, 'text': '20条/页' }
                ],
                totalPage: 28,
                showPageNum: 2,
                previousPage: '<i class="fa fa-angle-left" style="font-size: 20px;"></i>',
                nextPage: '<i class="fa fa-angle-right" style="font-size: 20px;"></i>',
                skip: '',
                confirm: 'Go',
                refresh: 'refresh',
                totalPageText: 'the total {} pages',
                isShowFL: false,
                isShowPageSizeOpt: false,
                isShowSkip: true,
                isShowRefresh: false,
                isShowTotalPage: false,
                isResetPage: false,
                callBack: function(currPage, pageSize) {
                    // console.log('currPage:' + currPage + '     pageSize:' + pageSize);
                    thisContext.initRonglianCommend(currPage);
                }
            });
        },
        /**
         * 原文推荐
         */
        origAnalysis: function() {
            $(".originality").html();
            $('.contentlabel').hide();
            $('.resource_recommend').hide();
            clearTimeout(similarityTimer); //关闭定时器
            //            	$('.original_analysis').show();
            // 启动定时器
            var lesstime = 90;
            thisContext.settime(lesstime);
            var mainGuid = $("#mainGuid").val();
            var ue = UE.getEditor("editer_");
            var contentTxt = ue.getPlainTxt();
            if (contentTxt.length < 100) {
                $.notify("文章长度不可少于100字！");
                return;
            }
            topUtil.ajaxRequest({
                type: "post",
                async: true,
                dataType: "json",
                url: cmedit.global.cmsPath + "RongZhiLianController/getSimilarity",
                data: {
                    mainGuid: mainGuid,
                    text: contentTxt,
                    mainType: 0
                },
                success: function(data) {
                    if (data.status) {
                        var articleHtml = '<p class="original_nums">文章原创度：<span class="originality"></span>' +
                            '<button type="button" class="btn btn-outline btn-default btn_radius blue active analysisBtn">分析</button>' +
                            '</p><ul class="original_ul" ><img style="text-align: center; margin: 0 auto;display: block;padding-top: 100px;" src="../../static/images/831.gif" class="loading_img" alt=""><li style="text-align:center;">正在请求分析…</li></ul>';
                        $("#analysisMessage").html(articleHtml);
                        // 获取推荐文章
                        similarityTimer = setTimeout('cmedit.EditSystem.getSimilarityArticle()', 10000);
                    } else { //获取原创度失败
                        $(".original_ul").html("获取原创度失败");
                    }
                }
            });
        },
        /**
         * 获取推荐的文章
         */
        getSimilarityArticle: function() {
            $(".cont_right>div").not(".messagetabs").hide();
            var mainGuid = $("#mainGuid").val();
            if (mainGuid == "") {
                thisContext.saveManuscript('auto');
                mainGuid = $("#mainGuid").val();
            }
            var ue = UE.getEditor("editer_");
            var contentTxt = ue.getPlainTxt();
            if (contentTxt.length < 100) {
                $.notify("文章长度不可少于100字！");
                return;
            }
            var html = '';
            topUtil.ajaxRequest({
                type: "post",
                async: true,
                dataType: "json",
                url: cmedit.global.cmsPath + "RongZhiLianController/getSimilarityArticle",
                data: {
                    mainGuid: mainGuid,
                },
                success: function(data) {
                    //判断是否已经执行过获取原创度操作
                    if (data.status) {
                        var lesstime = data.data.timer;
                        //    		            	lesstime = 100;
                        var result = data.data.result;
                        //判断是否已经获取到原创度相似文章
                        if (result == 0) { //已经获取到
                            var list = data.data.list;
                            var articleHtml = '';
                            if (list.length >= 0) {
                                articleHtml += '<p class="original_nums">文章原创度：<span class="originality">' + data.data.score + '</span>' +
                                    '<button type="button" class="btn btn-outline btn-default btn_radius blue active analysisBtn">分析</button>' +
                                    '</p><ul class="original_ul">';
                                var listData = {
                                    list: data.data.list,
                                }
                                articleHtml += template('articleListHtml', listData);
                                articleHtml += "</ul>";
                                //初始化echart
                                //        		            		for(var i=0; i<list.length; i++){
                                //        		            			thisContext.initEcharts("echart" + i,list[i].saWeight);
                                //        		            		}
                            } else { //原创度列表为空
                                articleHtml = '<p class="original_nums">文章原创度：<span class="originality"></span>' +
                                    '<button type="button" class="btn btn-outline btn-default btn_radius blue active analysisBtn">分析</button>' +
                                    '</p><ul class="original_ul">未查询到相似文章</ul>';
                            }
                            $("#analysisMessage").html(articleHtml);
                        } else if (result == 1) { //未获取到
                            var articleHtml = '<p class="original_nums">文章原创度：<span class="originality"></span>' +
                                '<button type="button" class="btn btn-outline btn-default btn_radius blue active analysisBtn">分析</button>' +
                                '</p><ul class="original_ul">未获取到，可重试</ul>';
                            $("#analysisMessage").html(articleHtml);
                        } else if (result == -1) { //获取中
                            var articleHtml = '<p class="original_nums">文章原创度：<span class="originality"></span>' +
                                '<button type="button" class="btn btn-outline btn-default btn_radius blue active analysisBtn">分析</button>' +
                                '</p><ul class="original_ul" ><img style="text-align: center; margin: 0 auto;display: block;padding-top: 100px;" src="../../static/images/831.gif" class="loading_img" alt=""><li style="text-align:center;">数据计算中，请稍后…</li></ul>';
                            $("#analysisMessage").html(articleHtml);
                            // 获取推荐文章
                            similarityTimer = setTimeout('cmedit.EditSystem.getSimilarityArticle()', 10000);
                        }
                        // 分析按钮禁用倒计时
                        if (lesstime > 0) {
                            $(".analysisBtn").attr("disabled", "disabled");
                            $(".analysisBtn").html('<span id="countDown">' + lesstime + '</span>秒');
                            // 启动定时器
                            thisContext.settime(lesstime);
                        }
                    } else {
                        // 未获取过原创度
                        html += '<p class="original_nums">文章原创度：<span class="originality"></span>' +
                            '<button type="button" class="btn btn-outline btn-default btn_radius blue active analysisBtn">分析</button>' +
                            '</p><ul class="original_ul">未分析，请点击进行分析</ul>';
                        $("#analysisMessage").html(html);
                    }
                    $(".analysisBtn").off('click').on('click', function() {
                        thisContext.origAnalysis($(this));
                    });
                    $(".original_analysis").show();
                }
            });
        },
        // 内容标签相关函数
        contentarrowFirst: function() {
            $(".figure").toggleClass("upOrDown")

        },
        contentarrowSecond: function() {
            $(".org").toggleClass("upOrDown")
        },
        contentarrowThird: function() {
            $(".local").toggleClass("upOrDown")
        },
        contentLabelAddActive: function(obj) {
            var name = $(obj).attr("name");
            sessionStorage.setItem('contentlabelSet', name);
            $(obj).addClass("active")
        },
        /**
         * 关键词分析
         */
        contentLabel: function() {
            $(".cont_right>div").not(".messagetabs").hide();
            clearTimeout(similarityTimer); //关闭定时器
            $('.contentlabel').show();
            var loadingHtml = '<img src="../../static/images/831.gif" class="loading_img" alt="" style="text-align: center; margin: 0 auto;display: block;padding-top: 100px;">';
            loadingHtml += '<li style="text-align:center;">标签加载中，请稍后…</li>';
            $("#contentlabelContent").html(loadingHtml);
            var title = $('#edit_title').val();
            var ue = UE.getEditor("editer_");
            var content = ue.getPlainTxt();
            topUtil.ajaxRequest({
                type: "post",
                async: true,
                dataType: "json",
                url: cmedit.global.cmsPath + "RongZhiLianController/getKeyWord",
                data: {
                    text: content,
                    title: title
                },
                success: function(data) {
                    if (data.status) { //关键词分析成功
                        var response = data.data;
                        var html = '';
                        html += '<div class="loading_top ">' +
                            '<div class="contentlabelContent" style="margin-top:10px;">' +
                            '<div class="clear"></div>' +
                            '<div class="first figure">' +
                            '<h3>人物标签<div class="img" onclick="cmedit.EditSystem.contentarrowFirst()"></div> </h3>';
                        if (response.person.length > 0) {
                            response.person.forEach(
                                function(item, index) {
                                    var linklist = JSON.stringify(item.linklist)
                                    html += '<div class="item " onclick="cmedit.EditSystem.contentLabelAddActive(this)" name=' + linklist + '>' +
                                        '<a  href="content_label.html" target="_blank"><span>' + item.name + '</span></a>' +
                                        '</div>';
                                }
                            )
                        } else {
                            html += '<div class="item" style="width:100%;color:red;line-height:23px;text-align:center;" >' +
                                '暂无人物标签' +
                                '</div>';
                        }

                        html += '</div>' +
                            '<div class="clear"></div>' +
                            '<div class="first org">' +
                            '<h3>机构标签<div class="img" onclick="cmedit.EditSystem.contentarrowSecond()"></div> </h3>';
                        if (response.org.length > 0) {
                            response.org.forEach(
                                function(item, index) {
                                    var linklist = JSON.stringify(item.linklist)
                                    html += '<div class="item " onclick="cmedit.EditSystem.contentLabelAddActive(this)" name=' + linklist + '>' +
                                        '<a  href="content_label.html" target="_blank"><span>' + item.name + '</span></a>' +
                                        '</div>';
                                }
                            )
                        } else {
                            html += '<div class="item" style="width:100%;color:red;line-height:23px;text-align:center;" >' +
                                '暂无机构标签' +
                                '</div>';
                        }

                        html += '</div>' +
                            '<div class="clear"></div>' +
                            '<div class="first local">' +
                            '<h3>地点标签<div class="img" onclick="cmedit.EditSystem.contentarrowThird()"></div> </h3>';
                        if (response.location.length > 0) {
                            response.location.forEach(
                                function(item, index) {
                                    var linklist = JSON.stringify(item.linklist)
                                    html += '<div class="item " onclick="cmedit.EditSystem.contentLabelAddActive(this)" name=' + linklist + '>' +
                                        '<a  href="content_label.html" target="_blank"><span>' + item.name + '</span></a>' +
                                        '</div>';
                                }
                            )
                        } else {
                            html += '<div class="item" style="width:100%;color:red;line-height:23px;text-align:center;" >' +
                                '暂无地点标签' +
                                '</div>';
                        }
                        html += '</div>' +
                            '</div>' +
                            '</div>';
                        $("#contentlabelContent").html(html);
                    } else { //关键词分析失败
                        $.notify(data.msg);
                    }
                }
            });
        },

        /**
         * 文档校对
         */
        jiaoDuiContentLabel: function() {
            $('.contentlabel').hide();
            $('.resource_recommend').hide();
            $(".original_analysis").hide();
            clearTimeout(similarityTimer); //关闭定时器
            $('.jiaoDuilabel').show();
            var loadingHtml = '<img src="../../static/images/831.gif" class="loading_img" alt="" style="text-align: center; margin: 0 auto;display: block;padding-top: 100px;">';
            loadingHtml += '<li style="text-align:center;">加载中，请稍后…</li>';
            $("#jiaoDuicontentlabelContent").html(loadingHtml);
            var title = $('#edit_title').val();
            var ue = UE.getEditor("editer_");
            var content = ue.getPlainTxt();
            thisContext.saveManuscript("auto");
            topUtil.ajaxRequest({
                type: "post",
                async: true,
                dataType: "json",
                url: cmedit.global.cmsPath + "LvController/addDocCorrectTask",
                data: {
                    text: content,
                    mainGuid: mainGuid,
                    serverCode: cmedit.global.cmedit_server_name
                },
                success: function(data) {
                    if (data.status) { //调用校对成功
                        thisContext.getLvDocResult(data.data);
                    } else { //关键词分析失败
                        $.notify(data.msg);
                        $('.jiaoDuilabel').hide();
                    }
                }
            });
        },

        /**
         * 定时获取校对结果数据
         * @param flag
         */
		getLvDocResult: function(taskId) {
			cacheTaskId = taskId;
			var retry = 0;
			var syncTimer = setInterval(function() {
				topUtil.ajaxRequest({
					async: false,
					type: 'POST',
					dataType: "json",
					url: cmedit.global.cmsPath + "LvController/getManuscriptDocCorrectResult",
					data: {
						taskId: cacheTaskId
					},
					success: function(data) {
						if (data.status == true) {
							if (data.data == null) {
								console.log("load....");
								if(retry==3){
									//同步成功
									window.clearInterval(syncTimer);
									var html = '';
									html += '<h7>' + data.data + '</h7>';
									$("#jiaoDuicontentlabelContent").html(html); 
								}
								retry++;
							}else if(data.data != taskId && data.data){
								window.clearInterval(syncTimer);
									var html = '';
									html += '<h7>' + data.data + '</h7>';
									$("#jiaoDuicontentlabelContent").html(html); 
							} 
							else if(data.data == taskId){
								//校对失败
								window.clearInterval(syncTimer);
								$.notify('校对失败...');
								$('.jiaoDuilabel').hide();
							}
						}  else {
							alert(data.msg);
						}
					},
					error: function(e) {
						alert("获取校对错误..."); //出现错误！
					}
				});
			}, 3000);
		},

        /**
         * 设置倒计时时间
         */
        settime: function(lesstime) {
            if (lesstime == 1) {
                $(".analysisBtn").html("分析");
                $(".analysisBtn").removeAttr("disabled");
                return;
            } else {
                lesstime -= 1;
                $(".analysisBtn").html(lesstime);
            }
            var lesstimer = setTimeout(function() { thisContext.settime(lesstime) }, 1000);
        },
        openOrigin: function(saSourceurl) {
            window.open(saSourceurl);
        },
        //-------------------------------------------------融之联相关结束---------------------------------------------

        //-------------------------------------------------厚键相关开始---------------------------------------------  
        /**
         * 打开厚键分享页面
         */
        hogeShare: function() {
            var header = $('.edit_title').val();
            var postData = {
                mainGuid: mainGuid,
                mainType: '0', //CMS稿件
                header: header,
                loadType: "HOGE_SHARE"
            };
            topUtil.ajaxRequest({
                type: "post",
                async: true,
                dataType: "json",
                url: cmedit.global.cmsPath + "HogeController/loadHJIMUrl",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        window.open(data.data, "HOGE");
                    } else {
                        $.notify("打开稿件分享页面失败");
                    }
                }
            });
        },
        /**
         * 打开cre协同平台分享页面
         */
        ducpShare: function() {
            var title = $('.edit_title').val();
            var ue = UE.getEditor("editer_");
            var content = ue.getPlainTxt();
            var postData = {
                "userId": userId,
                "tenantId": tenantId,
                "urlType": "FLEXIBLE_CENSOR",
                "customType": '4', //分享类型4:网页 
                "workId": mainGuid,
                "title": title,
                "content": content,
                "workBaseUrl": cmedit.global.portalPath,
                "workType": "1", //网页类型
                "portalKey": window.parent.localStorage.getItem("portalKey"),
                "clbGuid" : clbGuid
            };
            topUtil.ajaxRequest({
                type: 'POST',
                async: false,
                url: cmedit.global.portalPath + 'DucpController/getUrl',
                data: postData,
                success: function(data) {
                    if (data.status == 'true' || data.status == true) {
                        var url = data.data;
                        if (url.slice(0, 7) != "http://" || url.slice(0, 8) != "https://") {
                        	url = decodeURIComponent(url);
                        }
                        window.open(url, 'newwindow', 'height=400,width=600,top=100,left=700,titlebar=no,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=yes');
                    } else {
                        $.notify("打开协同平台分享页面失败");
                    }
                }
            });
        },
        /**
         * 打开厚键IM页面
         */
        hogeIM: function() {
            var postData = {
                loadType: "HOGE_IM"
            };
            topUtil.ajaxRequest({
                type: "post",
                async: true,
                dataType: "json",
                url: cmedit.global.cmsPath + "HogeController/loadHJIMUrl",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        alert(data.data);
                    } else {
                        $.notify("打开IM页面失败");
                    }
                }
            });
        },
        /**
         * 厚键任务页面
         */
        hogeTask: function() {

        },
        /**
         * 厚键message页面
         */
        hogeMessage: function() {

        },
        /**
         * 厚键消息数量统计
         */
        hogeMessageCount: function() {

        },
        //-------------------------------------------------厚键相关结束---------------------------------------------
        /**
         * @return 若符合对应的格式，返回true，否则返回false
         */
        chkFormat: function(str, ftype) {
            var nReg = Regexs[ftype];
            if (str == null || str == "") return false; // 输入为空，认为是验证通过
            if (ftype == 'num') {
                if (!nReg.test(str) && !chkChinese(str)) { // 10.23 tenfy
                    // 必须为数字且不能有中文
                    return true;
                } else {
                    return false;
                }
            }
            if (!nReg.test(str)) {
                return false;
            } else {
                return true;

            }
        },

        // 播放图标；
        toggleVideo: function(target, event) {
            if ($(target).parent().prev()[0].paused) {
                $(target).parent().prev().trigger("play");
                $(target).attr('src', '../../static/images/vstart.png');
            } else {
                $(target).parent().prev().trigger("pause")
                $(target).attr('src', '../../static/images/vend.png');
            }
        },
        btnPlayOver: function(target) {
            if ($(target).prev()[0].paused) {
                $(target).find("img").attr('src', '../../static/images/vend.png')
                $(target).find("img").css("display", "block");
            } else {
                $(target).find("img").attr('src', '../../static/images/vstart.png');
                $(target).find("img").css("display", "block");
            }
        },
        btnPlayOut: function(target) {
            if (!$(target).prev()[0].paused) {
                $(target).find("img").css("display", "none");
            }
        },
        /**
         * 对稿件的图片进行本地化
         */
        localizationImg: function(mainGuid) {
            // 先保存稿件
            //			if(!topUtil.isNotEmpty(mainGuid)){
            //            }
            thisContext.saveManuscript("auto");
            var ue = UE.getEditor("editer_");
            var content = ue.getContent();
            if (!content) {
                $.notify("未收集到需进行本地化图片");
                return false;
            }
            mainGuid = $("#mainGuid").val();
            topUtil.ajaxRequest({
                url: cmedit.global.cmsPath + "CmsController/localizationManuscript",
                type: 'POST',
                async: true,
                data: {
                    mainGuid: mainGuid
                },
                dataType: "json",
                success: function(data) {
                    if (data.status) {
                        var cmsManuscript = data.data;
                        //						var ue = UE.getEditor("editer_");
                        //						ue.setContent(cmsManuscript.cmsH5Content);
                        if ("null" == cmsManuscript || null == cmsManuscript) {
                            $.notify("无需本地化图片！！");
                        } else {
                            $.notify("图片本地化成功！！");
                            thisContext.initData();
                        }
                    } else {
                        $.notify(data.msg);
                    }
                }
            });
        },
        /**
         * 对稿件的图片进行是否本地化判断
         */
        isLocalizationImg: function() {
            //			thisContext.saveManuscript("auto");
            var mainGuid = $("#mainGuid").val();
            var isLocalization = false;
            topUtil.ajaxRequest({
                url: cmedit.global.cmsPath + "CmsController/isLocalization",
                type: 'POST',
                async: false,
                data: {
                    mainGuid: mainGuid
                },
                dataType: "json",
                success: function(data) {
                    if (data.status) {
                        isLocalization = data.data;
                    }
                }
            });
            return isLocalization;
        },
        /**
         * 判断当前稿件是否符合撤回条件
         */
        isRevokeManuscript: function(mainGuid) {
            var isRevoke = false;
            var postData = {
                "mainGuid": mainGuid,
            }
            topUtil.ajaxRequest({
                type: "post",
                async: false,
                //				contentType: "application/json;charset=UTF-8",
                dataType: "json",
                url: cmedit.global.cmsPath + "ManuscriptMainController/isRevokeManuscript",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        isRevoke = true;
                    }
                }
            })
            return isRevoke;
        },
        /**
         * 根据相关条件对稿件进行撤回
         */
        revokeManuscript: function() {
            var postData = {
                "mainGuid": mainGuid,
            }
            topUtil.ajaxRequest({
                type: "post",
                async: true,
                /*contentType: "application/json;charset=UTF-8",*/
                dataType: "json",
                url: cmedit.global.cmsPath + "ManuscriptMainController/revokeManuscriptMain",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        window.parent.cmedit.ManuscriptSystem.removeTab(mainGuid, false);
                    } else {

                    }
                }
            })
        },


    };

    return new EditSystemClass();
})(jQuery, window, document);
/*$(manuscriptSystem.init());*/
$(cmedit.EditSystem.init());
